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;




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.



Saturday, November 22, 2014

Linux: Run a program every hour

Saw this here (http://linux.die.net/Linux-CLI/scheduling.html):

You can also use the -f option to have at execute a particular file (a shell script).


at -f shell_script now + 1 hour

This would run the shell script 1 hour from now.



So I tested it as follows.  First, here is SAS program test_hourly.sas:

filename outbox email 'bqualls@firstanalytics.com';

data _null_;

file outbox
    to=('bqualls@firstanalytics.com')
    subject="Test hourly process"
    ;

put "This is a test run at &SYSDATE9 at &SYSTIME..";
put "This program will run again one hour from now.";
put " ";
put " ";
put " ";
put "(signed)";
put "The First Analytics Team";
run;



And here is the script:

#!/bin/bash
#schedule this same script to run again one hour from now
echo "sh test_hourly.sh" | at now + 1hr
#run sas program
sh runsas.sh test_hourly



And I started the script for this first time like this:

echo "sh test_hourly.sh" | at 5:30pm November 22



Note: must cd to the directory where test_hourly.sh exists before issuing the above instruction.



Thursday, November 13, 2014

Excel: #VALUE error when using SUMPRODUCT and INDIRECT

This is a weird one...

This gives #VALUE error:

     =SUMPRODUCT(INDIRECT("CP!"&ROW()&":"&ROW()),INDIRECT("CP!"&COLUMN()&":"&COLUMN()))

but this works:

     =SUMPRODUCT(INDIRECT("CP!"&SUM(ROW())&":"&SUM(ROW())),INDIRECT("CP!"&SUM(COLUMN())&":"&SUM(COLUMN())))

Got the answer from http://stackoverflow.com/questions/22746000/using-indirect-function-in-the-sumproduct-formula-for-true-false-cell-refere:

I'm not sure why you need INDIRECT instead of ordinary cell references but the specific problem here is that ROW function returns an "array", even when it returns a single value, e.g. it returns {"x"} rather than just "x" - and in some circumstances Excel can't process that.

Try wrapping the second ROW function in a SUM function - the value doesn't change but it gets rid of the array, i.e.

=SUMPRODUCT((INDIRECT("A2"):INDIRECT("A"&(ROW()-1))=INDIRECT("A"&SUM(ROW())))*1)

This will eliminate #VALUE! eror while leaving the essential structure of your formula unchanged.