I had a lot of trouble with SAS' FTP access engine. It appeared to be randomly corrupting the data. This worked though. I relied heavily on the indicated web page, and then converted it to a macro.
* ----------------------------------------------------- ;
* M A C R O : F T P F I L E
* ----------------------------------------------------- ;
* FTP the hard way...but to overcome failure of the
* FTP access engine, which corrupted the data.
* Source: https://communities.sas.com/message/114111
* Bill Qualls, 20150326
* ----------------------------------------------------- ;
%macro ftpfile(folder=&RAWDATA_FOLDER, file=, ftpcom=&RAWDATA_FOLDER/ftpcom.txt);
* file to which ftp commands will be written ;
filename ftpcom "&FTPCOM" lrecl=80;
data _null_;
file ftpcom;
* ftp ession user and password ;
put "user theuser thepassword";
* disable prompting cmd ;
put "prom no";
* enable binary transfer mode cmd ;
put "bin";
* go to local folder cmd ;
put "lcd &FOLDER";
* go to remote folder cmd ;
put "cd OurFolderOnFTPServer";
* send file cmd ;
put "send &file";
run;
* set up piping into ftp commands into ftp instruction ;
filename doftp pipe "ftp -n ftp.xxxxxxxx.com < &FTPCOM";
* enable ftp session and pass it the commands file ;
data _null_;
infile doftp;
input;
put _infile_;
run;
%mend ftpfile;
Thursday, March 26, 2015
Monday, March 23, 2015
Linux: Zipping files in Linux
My co-worker Ken shared this with me.
Here is how I am zipping files:
First, navigate to the directory where the files are located. Then,
zip –mT abc abc*
This creates the archive abc.zip, then adds to it all files
in the current directory named like abc*, then tests the archive (the T
option), then if test is OK, deletes the files (effectively moving the files to
the zip archive (the –m option)).
Saturday, March 14, 2015
SAS: FTP as SAS dataset as a SAS dataset
This summary is not available. Please
click here to view the post.
Monday, March 9, 2015
Linux: uptime command
A scheduled process stopped running. I wondered if perhaps the server had been shut down. Turns out there is a Linux command to check that: uptime.
[xcnb804@omhq1845 scripts]$ uptime
08:51:35 up 27 days, 38 min, 4 users, load average: 0.06, 0.10, 0.37
[xcnb804@omhq1845 scripts]$
About the command: http://linux.about.com/library/cmd/blcmdl1_uptime.htm
Unfortunately, server had not been shut down, so I still don't know the root cause of my problem....
Wednesday, February 18, 2015
SAS: Duplicate titles in PDF
I had duplicate titles in a PDF: once outside the graph and once inside the graph. Eliminated this with nogtitle and nogfootnote as follows:
ods _all_ close;
ods graphics / reset=all;
options orientation=portrait;
options papersize=(8.5in 11in);
* nogplot and nogtitle eliminates duplicated titles ;
ods pdf file="&OUTPUT_PDF" nogtitle nogfootnote ; * style=statistical ;
See https://communities.sas.com/message/144661
Tuesday, December 23, 2014
SAS: PROC TRANSPOSE and VAR _ALL_
If you want to rotate an entire table 90 degrees then use PROC TRANSPOSE. But this PROC defaults to transposing numeric variables only. So use var _all_ all follows:
data work.grandkids;
input name $ gender $ age mom $ dad $ ;
datalines;
Kamina F 8 Cora Peter
Raelani F 6 Cora Peter
Elliott M 3 Cora Peter
Callie F 1 Emma Nathan
;
run;
* defaults to numeric variables only;
proc transpose data=work.grandkids out=work.t1;
run;
* try one field such a name but it does not work ;
proc transpose data=work.grandkids out=work.t2;
var name;
run;
* use _all_ to transpose the whole darn thing ;
proc transpose data=work.grandkids out=work.t3;
var _all_;
run;
data work.junk;
input v1 $ v2 $ v3 $ v4 $ v5 $ v6 $ v7 $ v8 $;
datalines;
i want each word in its own row
;
run;
* this works ;
proc transpose data=work.junk out=work.t4;
var v1 v2 v3 v4 v5 v6 v7 v8;
run;
* this is easier ;
proc transpose data=work.junk out=work.t5;
var _all_;
run;
data work.grandkids;
input name $ gender $ age mom $ dad $ ;
datalines;
Kamina F 8 Cora Peter
Raelani F 6 Cora Peter
Elliott M 3 Cora Peter
Callie F 1 Emma Nathan
;
run;
* defaults to numeric variables only;
proc transpose data=work.grandkids out=work.t1;
run;
* try one field such a name but it does not work ;
proc transpose data=work.grandkids out=work.t2;
var name;
run;
* use _all_ to transpose the whole darn thing ;
proc transpose data=work.grandkids out=work.t3;
var _all_;
run;
data work.junk;
input v1 $ v2 $ v3 $ v4 $ v5 $ v6 $ v7 $ v8 $;
datalines;
i want each word in its own row
;
run;
* this works ;
proc transpose data=work.junk out=work.t4;
var v1 v2 v3 v4 v5 v6 v7 v8;
run;
* this is easier ;
proc transpose data=work.junk out=work.t5;
var _all_;
run;
Tuesday, November 25, 2014
SAS: Enterprise Guide AUTOEXEC
Wthin Enterprise Guide, if you name a Process Flow AUTOEXEC, EG will prompt you to run that process when you open the project. Note you need to name the Process, not the Program.
Subscribe to:
Posts (Atom)