Wednesday, 19 October 2011

Great Transposing Tip

"You blocked me on facebook and now you are going to die"

Transposing in SAS is a great feature, but I always forget how to do it. My very talented colleague made this little illustration to remind him how it works and now you can use it too!



/*          |  id
        ----+-----
        by  |  var       */


proc transpose data= bernard out= mark (drop=_:) prefix= title_;
      var data;
      id column_headings;
      by row_groups;
run;



Monday, 10 October 2011

Interleaving merge - so cool!

"I heard Cameron is actually C3P0 covered in wafer thin ham"

Here's a Great tip for merging. Ever got annoyed when you had to merge sorted datasets together and then had to re-sort because the order got messed up? Yeah, well not anymore buddy, because Marky boy's comin to the rescue!

data interleaved_set;
       merge dataset_1
                 dataset_2;
       by variable; *key bit!;
run;

The data step above will read in rows from both input datasets in order of the By variable. You can think of it as weaving the output together, or interleaving as it's called.

This saves a lot of time & memory because sorting is the memory intensive thing you can do in SAS.

Stay safe Sas fans, and yes, i'm accepting groupies. (Sas professionals only)

Tuesday, 4 October 2011

Normalising / Standardising Data in SAS

"I am pork boy, the breakfast monkey."


So here's a good procedure I came across today. If you ever need to quickly standardize a dataset then you can use the amazing Proc Standard!



PROC STANDARD DATA=cars MEAN=0 STD=1 OUT=zcars;
  VAR weight price ;
RUN;



This will standardize a dataset based on the normal distribution.  Boy I wish I knew about this a few months ago, it might of saved my job!