data work.admitfee;
set cert.admit;
run;
proc print data=work.admitfee;
var id name actlevel fee;
run;
9231 data work.admitfee; 9232 set cert.admit; 9233 run; NOTE: There were 21 observations read from the data set CERT.ADMIT. NOTE: The data set WORK.ADMITFEE has 21 observations and 9 variables. NOTE: DATA statement used (Total process time): real time 0.00 seconds cpu time 0.00 seconds 9234 proc print data=work.admitfee; 9235 var id name actlevel fee; 9236 run; NOTE: There were 21 observations read from the data set WORK.ADMITFEE. NOTE: PROCEDURE PRINT used (Total process time): real time 0.01 seconds cpu time 0.01 seconds
Syntax, PUTLOG statement
PUTLOG 'message';
Note: You can precede your message
text with WARNING, MESSAGE, or NOTE to better identify the output
in the log.
|
Variable
|
Description
|
Debugging Use
|
---|---|---|
_N_
|
The number of times
the DATA step iterated
|
|
_ERROR_
|
Initialized to 0, set
to 1 when an error occurs
|
Displays debugging messages
when an error occurs
|
data work.grades; set cert.class; Homework=Homework*2; AverageScore=MEAN(Score1 + Score2 + Score3 + Homework); if AverageScore<70; run;
NOTE: There were 4 observations read from the data set CERT.CLASS. NOTE: The data set WORK.GRADES has 0 observations and 6 variables. NOTE: DATA statement used (Total process time): real time 0.01 seconds cpu time 0.01 seconds
PUTLOG Name= Score1= Score2= Score3= Homework= AverageScore=;
29457 data work.grades; 29458 set cert.class; 29459 Homework=Homework*2; 29460 AverageScore=MEAN(Score1 + Score2 + Score3 + 29460! Homework); 29461 putlog Name= Score1= Score2= Score3= Homework= 29461! AverageScore=; 29462 if AverageScore<70; 29463 run; Name=LINDA Score1=53 Score2=60 Score3=66 Homework=84 AverageScore=263 Name=DEREK Score1=72 Score2=64 Score3=56 Homework=64 AverageScore=256 Name=KATHY Score1=98 Score2=82 Score3=100 Homework=96 AverageScore=376 Name=MICHAEL Score1=80 Score2=55 Score3=95 Homework=100 AverageScore=330 NOTE: There were 4 observations read from the data set CERT.CLASS. NOTE: The data set WORK.GRADES has 0 observations and 6 variables. NOTE: DATA statement used (Total process time): real time 0.01 seconds cpu time 0.01 seconds
data work.grades;
set cert.class;
Homework=Homework*2;
AverageScore = MEAN(Score1, Score2, Score3, Homework);
if AverageScore < 70;
run;
proc print data=work.grades;
run;
Syntax, PUT statement:
PUT specification(s);
|
data work.test; set cert.loan01; if code='1' then type='variable'; /*#1*/ else if code='2' then type='fixed'; else type='unknown'; if type='unknown' then put 'MY NOTE: invalid value: ' code=; /*#2*/ run;
1 | If the value of the variable Code
equals 1 , then the program returns
the value for Type as variable . If
the value equals 2 , then the return
value for Type is fixed . Otherwise,
the value of Type is returned as unknown .
|
2 | If Type contains the value unknown ,
then the PUT statement writes a message to the log.
|
NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column). 148173:11 148174:18 MY NOTE: invalid value: Code=3 MY NOTE: invalid value: Code=3 MY NOTE: invalid value: Code=3
data work.loan01;
set cert.loan;
if code='1' then type='variable';
else if code='2' then type='fixed';
else type='unknown';
put 'MY NOTE: The condition was met.';
run;
MY NOTE: The condition was met. MY NOTE: The condition was met. MY NOTE: The condition was met. MY NOTE: The condition was met. MY NOTE: The condition was met. MY NOTE: The condition was met. MY NOTE: The condition was met. MY NOTE: The condition was met. MY NOTE: The condition was met. NOTE: There were 9 observations read from the data set CERT.LOAN. NOTE: The data set WORK.LOAN01 has 9 observations and 6 variables.
data work.loan01;
set cert.loan;
if code='1' then type='variable';
else if code='2' then type='fixed';
else type='unknown';
put 'MY NOTE: Invalid Value: ' code= type= ;
run;
MY NOTE: Invalid Value: Code=1 type=variable MY NOTE: Invalid Value: Code=1 type=variable MY NOTE: Invalid Value: Code=1 type=variable MY NOTE: Invalid Value: Code=2 type=fixed MY NOTE: Invalid Value: Code=2 type=fixed MY NOTE: Invalid Value: Code=2 type=fixed MY NOTE: Invalid Value: Code=3 type=unknown MY NOTE: Invalid Value: Code=3 type=unknown MY NOTE: Invalid Value: Code=3 type=unknown NOTE: There were 9 observations read from the data set CERT.LOAN. NOTE: The data set WORK.LOAN01 has 9 observations and 6 variables.
data work.newcalc;
set cert.loan;
if rate>0 then Interest=amount*(rate/12);
else put 'DATA ERROR: ' rate= _n_ = ;
run;
DATA ERROR: Rate=. _N_=7 NOTE: There were 10 observations read from the data set CERT.LOAN. NOTE: The data set WORK.NEWCALC has 10 observations and 5 variables.
data work.admitfee; /*#1*/ set cert.admit; proc print data=work.admitfee; /*#2*/ var id name actlevel fee; /*#3*/
1 | Even though there is no RUN statement after the DATA step, the DATA step executes because the PROC step acts as a step boundary. |
2 | The PROC step does not execute. There is no following RUN statement for the step, nor is there a DATA or PROC step following the PROC PRINT step. Therefore, there is no indication that the step has ended. |
3 | The RUN statement is necessary at the end of the last step. If the RUN statement is omitted from the last step, the program might not complete processing and might produce unexpected results. |
run;
data work.admitfee; set cert.admit; run; proc print data=work.admitfee var id name actlevel fee; run;
9240 proc print data=work.admitfee 9241 var id name actlevel fee; --- 22 76 ERROR 22-322: Syntax error, expecting one of the following: ;, (, BLANKLINE, CONTENTS, DATA, DOUBLE, GRANDTOTAL_LABEL, GRANDTOT_LABEL, GRAND_LABEL, GTOTAL_LABEL, GTOT_LABEL, HEADING, LABEL, N, NOOBS, NOSUMLABEL, OBS, ROUND, ROWS, SPLIT, STYLE, SUMLABEL, UNIFORM, WIDTH. ERROR 76-322: Syntax error, statement will be ignored. 9242 run
HIGH
in the program
below, cause SAS to misinterpret the statements in your program.
data work.admitfee;
set cert.admit;
where actlevel='HIGH;
run;
proc print data=work.admitfee;
var id name actlevel fee;
run;
*'; run;
data work.admitfee;
set cert.admit;
where weight>180 and (actlevel='MOD' or actlevel='LOW);
run;
proc print data=cert.admit keylabel;
label actlevel='Activity Level';
run;
9254 proc print data=cert.admit keylabel; -------- 22 202 ERROR 22-322: Syntax error, expecting one of the following: ;, (, BLANKLINE, CONTENTS, DATA, DOUBLE, GRANDTOTAL_LABEL, GRANDTOT_LABEL, GRAND_LABEL, GTOTAL_LABEL, GTOT_LABEL, HEADING, LABEL, N, NOOBS, NOSUMLABEL, OBS, ROUND, ROWS, SPLIT, STYLE, SUMLABEL, UNIFORM, WIDTH. ERROR 202-322: The option or parameter is not recognized and will be ignored. 9255 label actlevel='Activity Level'; 9256 run; NOTE: The SAS System stopped processing this step because of errors.