SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
GN0001
Barite | Level 11
Data sales;
Input dept: $10.  Jan feb mar;
Datlines;
Shoes 4344 355 266
Houseware 33 44 55
;
Data _null_;
Set sales;
qtrTot = jan + feb + mar;
put ‘total quarterly sales: ‘
qtrtot dollar12.:
Run;
Blue Blue
1 ACCEPTED SOLUTION
6 REPLIES 6
Sajid01
Meteorite | Level 14

In the present scenario it does not create any new dataset.

GN0001
Barite | Level 11
Thanks for the response.
Is its result used in another statement?
Is it save in memory for further use?
Regards,
Blue Blue
Blue Blue
Sajid01
Meteorite | Level 14
Within the same data step yes.
Since no data step is created no disk space is needed,
Reeza
Super User

It can be used when you want to use data step logic/processing to either create code (call execute), create macro variables (call symputx), or write to an external tex file (file) without also creating a data set.

 

There are other uses, but those are some of the most common. 

ballardw
Super User

The data _null_ allows you use SAS coding in data step that does not require creating a new data set.

Expensive pocket calculator:

 

Data _null_;
   x = 1 + 2 + 3 + 4 + 5;
   put x= ;
run;

Puts the result to the log

 

Write to the results window:

Data _null_;
  file print;
   x = 1 + 2 + 3 + 4 + 5;
   put x= ;
run;

Write to an external file:

Data _null_;
   file "c:\folder\sometextfile.txt";
   x = 1 + 2 + 3 + 4 + 5;
   put x= ;
run;

With data on a SET statement then you can write any of that out, such as create custom file layout that Proc Print wouldn't. 30 years ago I worked for an agency that used this approach to write text markup that our fancy (read big as car) high production laser printer used to make "nice" tables and graphics that we called "Proc AnnualReport".

 

This usage has been expanded with the File ODS and/ or the Report writing interface.

Create macro variables with Call symputx/symput.

Create calls to Call Execute that stacks code into the execution buffer for execution after the data step terminates.

Make noise  (I used to use this to tell me when some longish running jobs were finished )

data _null_;
   call sound(523,2000);
run;

Generally do something that does not require creating an output data set when you want to use data or fixed elements of coding.

 

 

 

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 9169 views
  • 2 likes
  • 5 in conversation