Data are stored in a directory. You can give a name to that directory using the 'libname' statement.
LIBNAME name_of_the_libraray"W:/Desktop" ;
The Proc datasets allow to list the content of all the datasets in a library
libname lib"W:\…\data";proc datasetslibrary = lib; contents data=_all_;run;
The following program draws 5 observations from a normal distribution with expectancy 1.75 and standard deviation 0.1. The rannor() function draws from a standard normal distribution. The argument specifies theseed. This allows reproducibility.
datataille ;do i =1 to5 ;x =1.75 +0.1 *rannor(1) ;output ;end; run;
If you know the quantile function (inverse CDF), you can draw in the distribution using the inverse CDF method. You simple have to draw in a uniform distribution and transform the draw using the inverse CDF function. Here is an example with a Gumbel distribution :
gumbel = -log(-log(ranuni(0))) ;
database ;inputx u ;cards ;1 -1213 -1415 -1;run ;proc printdata = base; run;
proc sortdata=lib.dataout=lib.data2 tagsort;by x1 x2; run;
The default is ascending sort. If you want to put the highest values first, you can useby descending.
proc sortdata=lib.dataout=lib.data2 tagsort;by x1 descending x2; run;
It is better to sort the data before merging them.
datalib_name.data_name3;merge lib_name.data_name3 (in=a) lib_name.data_name2 (in=b);by x1;if aand b; run;
DATAa;INPUT famid name $ inc98;DATALINES;2 Art220001 Bill300003 Paul25000;RUN;DATAb;INPUT famid inc96 inc97 inc99;DATALINES;3750007600077000140000405004100024500045400458004200300100;RUN;PROC SORTDATA=a;BY famid;RUN;PROC SORTDATA=b;BY famid; RUN;DATAmerge121;MERGE a(in = a) b(in = b) ;BY famid; froma = a; fromb = b;RUN;
You can import from a CSV:
proc importdatafile="E:/Data/recidiv.csv"out=lib.recidivreplace;run;
You can also specify the delimiter.
proc importdatafile='W:/…/australia2.csv'out=work.australiareplace;delimiter =";";run;
You can import from an xls file.
proc importdatafile="C:/Documents and Settings/.../Bureau/base.xls"out=work.basereplace;sheet ="Table 1";run;
First one can export to Excel :
PROC EXPORTDATA= lib.database OUTFILE="W:/Desktop/export.xls" DBMS=EXCEL2000REPLACE;RUN;
One can create aggregate table using the output delivery system (ODS). The following program creates a table of the cross tabulation and store it in a new dataset.
ods traceon ; odsoutput CrossTabFreqs = lib.aggregate ; ods listing close;proc freqdata = lib.ficus (where = (effec <100));table effec * eff_moy;run; odsoutput clear ; odsoutput close ; ods trace off ; ods listing ;