Uploaded by sas sys

null

advertisement
/*_NULL_*/
It has been the author's experience that in many job interviews where SAS
programming is an important part of the job description there are questions about
"data _null_." It appears that employers consider this a sort of "litmus test" of the
level of a candidate's ability. Therefore, it is important that we give a little attention
to this topic.
The idea of "null" here is that we have a data step that actually doesn't create a data
set. For a data set name, we use the special name "_null_" where the underscores are
part of the name. This causes SAS to carry out the commands in the data step, but as
far as the output is concerned, it is, well, "null" or nothing.
Why have a data step that doesn't save anything? Actually, it doesn't save a data set,
but it can save something else, in particular, a text file. Thus, a data step can be used
for report writing or the creation of "raw data" files.
The process is simply the reverse of reading a raw data file. Instead of an "infile"
statement, there will be a "file" statement. Instead of "input," there will be "put."
DATA _NULL_;
file "D:\CLASS_10apr2019\data.rtf";
/*file print;*/
put @25 'YASHODHA HOSPITALS';
put @30 'SEC’BAD';
put
'_____________________________________
_______________________';
put @1 'Patient name:' @21 'Age:' @34
'Sex:' @45 'Contact:';
put
'_____________________________________
_______________________';
put ;
put @1 'Rx';
put @6 '1.';
put @6 '2.';
put ;
put ;
put ;
put ;
put ;
put ;
put ;
put ;
put ;
put ;
put ;
put @1 'Notes:';
put ;
put ;
put @1 'Next Visit:';
run;
/*case2*/
data _null_;
file print;
if exist("sashelp.dm")=1 then put
'present';
else put 'absent';
run;
Download