DATA Cars1
DATA Cars1
DATA Cars1
cars1
OBS
1
2
3
4
5
data
MAKE
AMC
AMC
AMC
Buick
Buick
MODEL
Concord
Pacer
Spirit
Century
Electra
MPG
22
17
22
20
15
WEIGHT
2930
3350
2640
3250
4080
PRICE
4099
4749
3799
4816
7827
DATA cars5;
INFILE "c:\carsdata\cars5.dat" delimiter=',';
INPUT make $ model $ mpg weight price;
RUN;
TITLE "cars5 data";
PROC PRINT DATA=cars5(OBS=5);
RUN;
cars5 data
OBS
1
2
3
4
5
MAKE
AMC
AMC
AMC
Buick
Buick
MODEL
Concord
Pacer
Spirit
Century
Electra
MPG
22
17
22
20
15
WEIGHT
2930
3350
2640
3250
4080
PRICE
4099
4749
3799
4816
7827
data prep;
length name $16;
set sashelp.class;
gender = sex; run;
DATA= specifies the dataset to be processed, PROMPT invokes the prompting mode, sort of
like a wizard NOWINDOWS suppresses the REPORT window and directs the report to the output
window REPORT = specifies a stored report to be used in generating a new report OUTREPT=
names a location to store the report OUT= creates a SAS data set HEADLINE creates a
horizontal line between the column headers and the body of the report HEADSKIP creates a
blank line between the column headers and the body of the report
PROC REPORT NOWD DATA=SURVEY HEADLINE HEADSKIP CENTER MISSING;
COLUMNS FNAME LINIT NAME SEX ACADYEAR GPA AGE
ID A B
ID C
10 1 2
20 3 4
30 5 6
10 0
20 5
30 7
This data step does a merge of data set one and two by ID:
data three;
merge one two;
by id;
run;
PROC PRINT DATA=auto;
WHERE rep78 >= 3;
VAR make rep78;
RUN;
PROC PRINT DATA=auto;
WHERE rep78 >= 3;
VAR make rep78;
RUN;
PROC FREQ DATA=auto;
TABLES rep78*foreign ;
RUN;
PROC FREQ DATA=auto;
WHERE rep78 >= 3;
TABLES rep78*foreign ;
RUN;
PROC PRINT DATA=auto;
WHERE rep78 <= 2;
VAR make price rep78 ;
RUN;
PROC PRINT DATA=auto;
WHERE rep78 <= 2 and rep78 ^= . ;
VAR make price rep78 ;
RUN;
PROC PRINT DATA=auto;
WHERE . < rep78 <= 2;
VAR make price rep78 ;
RUN;