Read Text: Sas My Code
Read Text: Sas My Code
Read Text: Sas My Code
Infile function
DSD=[ “m” get rid of quotation mark,2,,2= in this case (csv) ,, means missing value]
MISSOVER = scan file and show missing value
FIRSTOBS = 2[first observation is second line]
For string value column variable name should end with $ example source$
data weightgain;
infile "/home/u49490499/main/weightgain (2).csv" dsd missover firstobs=2;
input id source$ type$ weightgain;
run;
READ CSV by data
proc import out=weight datafile="/home/u49490499/main/weightgain (2).csv" dbms=csv;
run;
proc print data=weight;run;
Getnames=yes/no(default=yes)
Yes get first row column name as variable
Data name;
Set df1 df2(rename=(names=columnname));
Run;
SAS functions
Rand ====Generate random numbers
Data …;
CALL Streaminit(12345);
Do i=1 to n;
Newvar = rand(“Normal”)
OUTPUT ;
End;
Run;
Length(doesnot count blank) Lengthn(same as first but if “ ” this counts 0) Lengthc(count blanks)=Specify
length of data in variable
Numavailable = coalesce(var1,var2);
Run;
Show available
Function end with n like lengthn ===n for numerical
If end with c like lenghc====c for character
FLEXIBLE PROGRAMMING
Filename sales “directory/mon*.txt”; ===== read every file with mon name in it and save in sales variable to use
Data rollingquarater;
Infile sales dlm=’,’;
Input cutomer_id$ order_id order_type order_date : date9. Delivery_date : date9.;
Run;
SAS MY CODE
VISUAL Representation
Scatter plot
BAR GRAPH
Proc gchart data=name;
Title “ naMMMMMAEAE”;
Format price dollar9;
Vbar price tax/ group =type;
Pattern color =yellow;
Run;
Statistical Analysis