How to read the latest file in sas mainframes - sas

I have a bunch of files like :
EESE.ABC123.ECIM.SAS.D160128,
EESE.ABC123.ECIM.SAS.D160202,
EESE.ABC123.ECIM.SAS.D160328,
EESE.ABC123.ECIM.SAS.D160502
I only want to read the latest created (D160502) file in mainframes using sas. Any help would be appreciated.

If you can use JCL then the following statement :
abc123 DD DSN=EESE.ABC123.ECIM.SAS(0), DISP=SHR
then in SAS use infile statement:
infile abc123 ;
it will take latest file. Hope this helps
** I don't know whether you are using JCL or not, so posted with JCL in case it might help you.

Related

Emacs regexp - replacing text strings, query replace regexp

It seems simple enough but I can't get it done.
My text file looks like this :
Johnson Cary, 2009, This important article, 109 pages.
Smith Tom, 2003, Much ado about nothing: a study, 89 pages.
I need this :
Johnson Cary%2009%This important article%109 pages.
Any special character unlikely to appear in text will do. The end goal is to end up with a .csv then a .xls file.
I am using
^\([^,]+\)\([,]\)
to find the first occuring comma but when I try to replace with
\1 %
it does not work, nor any kind of close combination of that sort for that matter.
Any help will be dearly welcome!
Thank you much in advance.
Replace this:
^\([^,]*\), \([^,]*\), \([^,]*\), \(.*\)$
with this:
\1%\2%\3%\4
to get the correct result.

Using regexp in a windows bat file with BRC32 renaming utility

I am using Windows XP and wrote a simple bat file that goes out and downloads XML from a website then it renames the xml files so they all have a .zip extension but for some reason it won't rename the files. Here is the line of code that doesn't work using BRC32, it seems to have trouble doing a REGEXP in windows.
.\software\BRC32 /DIR: /REGEXP:.*%22(.*)%22:\1.zip /EXECUTE
File Name: download#down_stds=all&down_typ=results&cond=%22Aicardi Syndrome%22
Desired result: download#down_stds=all&down_typ=results&cond=%22Aicardi Syndrome%.zip
I am using the BRC32.exe utility that also uses the pcre.dll version 3.9 to do the REGEXP in the bat file, but for some reason I just get an error that says the file could not be renamed. Does anyone have any insight into this problem>?
Changing '%' to '%%' in the script fixed my problem
Since you don't say what BRC32' syntax is, I'd make a guess at the /REGEXP:.*%22(.*)%22:\1.zip part.
If the parser doesn't object to %22(,*)% it's likely to be resolved to [nothing].
If you really want to poke % as a parameter-character, then try doubling the %s since % escapes %.
But also, 22 look ssuspiciously like a " to me. Possibly you could replace the %22 with " - but without knowing exactly what the parameter means, it's hard to advise.
But ."(.*)"\1.zip looks very strange too...
yep. adding another % sign fixed it. damn I feel so stupid

Weka with Missing Values

I've a question about weka as this person:
Hi all:
I felt really strange about WEKA on this.
I have prepared a CSV file which has lots of missing values. One
missing value in this file is basic just no any value between pair of
commas i.e. ,random_value1,,random_value2. This is an example of the
format. You can see there is a pair of commas, between them is just
nothing not even a white_space, and it should indicates a missing
value of the data.
The weird thing is when I read this CSV into WEKA, WEKA assigns all
missing values to a question mark, i.e. '?'. This is exactly how WEKA
expresses it.
And then when I run testing analysis, WEKA started working on these
'?' as some sort useful information. It just missing values, could
WEKA please just jump over it?
These problem became really wasting. Analysis results read like if
missing then value missing, missing assocciates with missing, missing
correlates missing.
Can WEKA reads missing value as missing value, not some sort question
marks? Or can I tell WEKA that for all '?', treat them as missing
values?
Thanks guys
He solved his problem using this solution:
I found a way to tell WEKA about the missings. Just use the fine_and_replace function of a ASCII editor, replace all '?' to ?.
>
but I didn't know how can download ASCII Editor and use it ,, can anyone inform me ????
I suggest you to use notepad2 or notepad++ in windows.
You don't have to work on with missing values. Different algorithms work differently on missing values. So, don't worry, it will be handled just the way it should have been.

sas one-liner

Is there a way to run a one-liner in sas, or do I have to create a file? I'm looking for something like the -e flag in perl.
My favourite is using the -stdio option
Either:
sas -stdio
Then start typing. Or ...
echo "proc options; run;" | sas -stdio
The Unix version of SAS was ported from MVS years ago and to make a long story short, the SAS executable does not import from STDIN. To make this work in Unix, merely alter slightly the previous suggestion into something like:
echo "your SAS code" > temp;sas -sysin temp
Hope this is helpful.
sas -initstmt '%put hello world ; endsas ;'
sas -initstmt 'proc print data=sashelp.class; run ;'
Off course this could also be:
sas -initstmt '%inc large_program.sas; endsas;'
Never having used sas, what I might try is something like:
echo <insert sas code here> | sas --execute-file -
Oftentimes applications will let you specify '-' as a file to have it read from STDIN. And 'echo' just prints its arguments out, and the | connects them together.
You could also use the -nodms option. This will give you a command line version of Base.

Combining values from different files into one CSV file

I have a couple of files containing a value in each line.
EDIT :
I figured out the answer to this question while in the midst of writing the post and didn't realize I had posted it by mistake in its incomplete state.
I was trying to do:
paste -d ',' file1 file2 file 3 file 4 > file5.csv
and was getting a weird output. I later realized that was happening because some files had both a carriage return and a newline character at the end of the line while others had only the newline character. I got to always remember to pay attention to those things.
­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
file 1:
1
2
3
file2:
2
4
6
paste --delimiters=\; file1 file2
Will yield:
1;2
3;4
5;6
I have a feeling you haven't finished typing your question yet, but I'll give it a shot still. ;)
file1: file2: file3:
1 a A
2 b B
3 c C
~$ paste file{1,2,3} |sed 's/^\|$/"/g; s/\t/","/g'
"1","a","A"
"2","b","B"
"3","c","C"
Or,
~$ paste --delimiter , file{1,2,3}
1,a,A
2,b,B
3,c,C
you probably need to clarify or retag your question but as it stands the answer is below.
joining two files under Linux
cat filetwo >> fileone
Also don't forget about the ever versatile LogParser if you're on Windows.
It can run SQL-like queries against flat text files to perform all sorts of merge operations.
The previous answers using logparser or the commandline tools should work. If you want to do some more complicated operations to the records like filtering or joins, you could consider using an ETL Tool (Pentaho, Mapforce and Talend come to mind). These tools generally give you a graphical palette to define the relationships between data sources and any operations you want to perform on the rows.