SAS Command Explanation
SAS Functions 1 Listing of SAS Functions
SAS Functions 2 Listing of SAS Functions
goptions hsize=3in vsize=4in horigin=1in vorigin=2in; Size specification and location of graphs.
libname myname "~/sub1/sub2";
libname myname "K:\sub1\sub2";
data myname.set_one;
(do stuff ...)
Using LIBREF in UNIX vs. PC
options nonotes; Eliminate LOG output.
PROC gPLOT DATA=OUT1; PLOT D*H=1 P1*H=2/OVERLAY; TITLE 'D = DEGREE SIX POLYNOMIAL IN H'; symbol1 v=diamond i=none h=4 c=red; symbol2 v=none i=join c=green; Gplot statements.
if a=0 then
do;
if b=0 then prod_ab=1;
else prod_ab=a**b;
end;
else prod_ab=a**b;
The correct way in IML to do "IF A=0 AND B=0 THEN DO STUFF, OTHERWISE DO STUFF".
if a=0 then
*do;
if b=0 then prod_ab=1;
else prod_ab=a**b;
*end;
else prod_ab=a**b;
The incorrect way in IML to do "IF A=0 AND B=0 THEN DO STUFF, OTHERWISE DO STUFF". Doing this in the regular datastep in SAS should be okay.
if ((a=0) & (b=0)) then prod_b=1; else prod_ab=a**b; The easiest way in IML to do the above. In regular SAS, replace the ampersand with the word AND.
data one;
set orig;
file '/afs/unity.ncsu.edu/users/
j/jadoi/research/file_name';
put x y z;
run;
Output data into a textfile called file_name ==> this method does not include headers so will be directly accessible by Matlab.
add statsas
sas
Access to StatXact. Do not use add sas after add statsas. This will call SAS8 and will not work.
x 'cd research/class/st750/files; macheps.exe;'; This command stops the SAS process, falls into an xterm window, and performs whatever command within the single quotes. The next command will begin only after the xterm command is completed.
proc datasets; delete myname; Deletes the dataset myname.
free mymatrix; [in IML] Deletes mymatrix -- useful if the matrix needs to be cleared prior to using it again within an embedded loop.
Using LABELS in IML
********************;
*PGM1;
do i = 1 to 5;
   if i = 4 then;
   goto i_out;
   else
   print i;
end;

i_out: print 'i out';
*********************;
*PGM2;
start hello;
do i = 1 to 5;
   if i = 4 then;
   goto i_out;
   else
   print i;
end;

i_out: print 'i out';
finish hello;
call hello;

The use of the label in PGM1 doesn't work. In this situation, replace {goto i_out;} with {STOP;}. In NON-MODULE IML, the STOP statement will cause IML to drop out of ALL loops it is ne sted within and continue with the following statements.

HOWEVER, in MODULE IML, the {STOP} statement causes the entire code to HALT -- nothing continues. As shown in PGM2, the LABEL in this works to serve the same purpose STOP would serve in PGM1.

filename myfile "c:\sas\data";

data _null_;

infile myfile(newdata);

input sales expenses;

file myfile(jandata) MOD;

put sales expenses; run;
Appending Data to an External File (MOD)

This example reads the variables SALES and EXPENSES from the external data file C:\SAS\DATA\NEWDATA.DAT and appends records to the existing data file C:\SAS\DATA\JANDATA.DAT.

If you are going to append data to several files in a single directory, you can use the MOD option in the FILENAME statement instead of in the FILE statement. You can also use the FAPPEND function or the PRINTTO procedure to append data to a file.