Two steps: data and proc

There are basically two steps doing things in SAS. one is creating, manipulating data, The DATA step and another is all other functions including statistical, the PROC step.

I will cover both steps and many procedures later but here is quick look for how to use them.

Use DATA STEPS to:

    • Create and import data:

data data1;
input a b c;
cards;
1 2 3
4 5 6
7 8 9
;
run;

The result is the following table

Obs a b c
1 1 2 3
2 4 5 6
3 7 8 9

data data3;
infile 'D:/sas/data3.dat';
input a b c d;
run;

This will read data3.dat file into data3 which has four variables as given in input statement.

data

random1;

data random1;
do i = 1 to 10;
x = normal(0);
y = uniform(0);
output;
end;
run;

The result is the following table
Obs i x y
1 1 -1.52857 0.41513
2 2 0.08083 0.53118
3 3 1.98095 0.32572
4 4 -0.26286 0.38283
5 5 -0.01880 0.21665
6 6 -0.04803 0.43361
7 7 -1.46001 0.46454
8 8 1.19792 0.13875
9 9 -1.63991 0.31687
10 10 1.00099 0.07637

 

    • Modify and manipulate data:

data data2; set data1;
d=(a+b)/c;
loga=log10(a);
drop a;
run;

The result is the following table

Obs b c d loga
1 2 3 1.00000 0.00000
2 5 6 1.50000 0.60206
3 8 9 1.66667 0.84510

data

random2; set random1;

data random2; set random1;
if x<0 then out1='Neg';
else out1='Pos';
if y<.5 then out2='F';
else out1='P';
run;

The result is the following table
Obs i x y out1 out2
1 1 -1.52857 0.41513 Neg F
2 2 0.08083 0.53118 Pos P
3 3 1.98095 0.32572 Pos F
4 4 -0.26286 0.38283 Neg F
5 5 -0.01880 0.21665 Neg F
6 6 -0.04803 0.43361 Neg F
7 7 -1.46001 0.46454 Neg F
8 8 1.19792 0.13875 Pos F
9 9 -1.63991 0.31687 Neg F
10 10 1.00099 0.07637 Pos F

 

Use PROC STEPS to:

  • Sort data (PROC SORT)
  • Statistical summary (PROC MEANs, PROC UNIVARIATE)
  • Graphics (PROC PLOT, PROC GPLOT)
  • Many Statistical procedures (PROC GLM, PROC MIXED, PROC PRINCOMP, …)
  • Advanced data techniques (PROC SQL)
  • Matrix operations (PROC IML)
  • ……………and many more

I will discuss many topics later

0 comments: