天天看點

SAS Notes---2017/9/26

1, GAMMA function could be used to calculate the factorial of an integer in SAS.

GAMMA(x+1) = x !

2, Import Excel file.

(1)The first way is to first change the Excel file into a CSV file and then import CSV file.

(2)Another way is to use the following procedure. This method applies to excel 2007 version and above. And it also allows us to import certain sheet of the Excel file.

proc import out=city
    datafile='C:\Users\Administrator\Desktop\cityinfo.xlsx'
    dbms=xlsx replace;
    sheet='sheet3';
    getnames=yes;
run;
           

3, Cumulative statement

The following two data steps could generate the same results.

DATA TEST;
    DO I= TO ;
        N+1;
        OUTPUT;
    END;
    DROP I;
RUN;
           
DATA TEST;
    RETAIN N=0;
    DO I=  TO ;
        N=N+1;
        OUTPUT;
    END;
    DROP I;
RUN;
           

Certainly, we should know that the following code cannot function, since N has not been initialized.

DATA TEST;
    DO I=  TO ;
        N=N+1;
        OUTPUT;
    END;
    DROP I;
RUN;