data work.update;
infile invent obs=10;
input Item $ 1-13 IDnum $ 15-19
InStock 21-22 BackOrd 24-25;
Total=instock+backord;
run;
data work.test;
infile loan;
input Code $ 1 Amount 3-10 Rate 12-16
Account $ 18-25 Months 27-28;
if code='1' then type='variable';
else if code='2' then type='fixed';
else type='unknown';
if type='unknown' then put 'MY NOTE: invalid value:' code=;
run;
1
or 2
,
the PUT statement writes a message to the log:
MY NOTE: invalid value: Code=V NOTE: 9 records were read from the infile LOAN. The minimum record length was 28. The maximum record length was 28. NOTE: The data set WORK.TEST has 9 observations and 6 variables. NOTE: DATA statement used (Total process time): real time 0.01 seconds cpu time 0.03 seconds
Syntax, PUT statement:
PUT specification(s);
|
put 'MY NOTE: The condition was met.';
MY NOTE: The condition was met. NOTE: 9 records were read from the infile LOAN. The minimum record length was 28. The maximum record length was 28. NOTE: The data set WORK.TEST has 9 observations and 6 variables. NOTE: DATA statement used (Total process time): real time 0.01 seconds cpu time 0.01 seconds
put 'MY NOTE: invalid value: 'code type;
MY NOTE: invalid value: V unknown NOTE: 9 records were read from the infile LOAN. The minimum record length was 28. The maximum record length was 28. NOTE: The data set WORK.TEST has 9 observations and 6 variables. NOTE: DATA statement used (Total process time): real time 0.00 seconds cpu time 0.00 seconds
put 'MY NOTE: invalid value: 'code= type=;
MY NOTE: invalid value: Code=V type=unknown NOTE: 9 records were read from the infile LOAN. The minimum record length was 28. The maximum record length was 28. NOTE: The data set WORK.TEST has 9 observations and 6 variables. NOTE: DATA statement used (Total process time): real time 0.01 seconds cpu time 0.00 seconds
put 'MY NOTE: invalid value: '
code= _n_= _error_=;
MY NOTE: invalid value: Code=V _N_=3 _ERROR_=0 NOTE: 9 records were read from the infile LOAN. The minimum record length was 28. The maximum record length was 28. NOTE: The data set WORK.TEST has 9 observations and 6 variables. NOTE: DATA statement used (Total process time): real time 0.01 seconds cpu time 0.01 seconds
put 'MY NOTE: invalid value: ' _all_ ;
MY NOTE: invalid value: Code=V Amount=10000 Rate=10.5 Account=101-1289 Months=8 type=unknown _ERROR_=0 _N_=3 NOTE: 9 records were read from the infile LOAN. The minimum record length was 28. The maximum record length was 28. NOTE: The data set WORK.TEST has 9 observations and 6 variables. NOTE: DATA statement used (Total process time): real time 0.01 seconds cpu time 0.01 seconds
data finance.newcalc;
infile newloans;
input LoanID $ 1-4 Rate 5-8 Amount 9-19;
if rate>0 then
Interest=amount*(rate/12);
else put 'DATA ERROR ' rate= _n_=;
run;