BookmarkSubscribeRSS Feed
rodolfo_1
Fluorite | Level 6

Hello All,

 

While running next code I realized that if I specify the data or not in the proc means statement, the result and the log is the same, however, I can't find documentation about this behavior, since all the information states that data should be entered, Could you please let me know if this is a normal behaivor?

 

Thank you in advance.

 

 

data VS;
input id sbp dbp sex $ age wt;
datalines;
1 120 80 M 15 115
2 130 70 F 25 180
3 140 100 M 89 170
;
run;

proc means;
run;

 

*same result if proc means data=VS; is entered;

5 REPLIES 5
Kurt_Bremser
Super User

SAS procedures that require input datasets with a data= option will automatically use the last created dataset if no such option is specified.

See Input Datasets in the documentation.

rodolfo_1
Fluorite | Level 6

Thank you Kurt

 

novinosrin
Tourmaline | Level 20

Please take a look at the below 2 links that gives some insight. Thanks

 

http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#a000210371.htm

 

http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000279128.htm

 

Basically SAS references the most recently created dataset as set in 

_LAST_= System Option 

 

 

 


@rodolfo_1 wrote:

Hello All,

 

While running next code I realized that if I specify the data or not in the proc means statement, the result and the log is the same, however, I can't find documentation about this behavior, since all the information states that data should be entered, Could you please let me know if this is a normal behaivor?

 

Thank you in advance.

 

 

data VS;
input id sbp dbp sex $ age wt;
datalines;
1 120 80 M 15 115
2 130 70 F 25 180
3 140 100 M 89 170
;
run;

proc means;
run;

 

*same result if proc means data=VS; is entered;


 

rodolfo_1
Fluorite | Level 6

Thank you novinosrin, I'll review this links.

 

Regards,

Rodolfo.

Tom
Super User Tom
Super User

Seems be documented to me.  Here is link to syntax documentation.

https://documentation.sas.com/?docsetId=proc&docsetTarget=n1qnc9bddfvhzqn105kqitnf29cp.htm&docsetVer...

 

The DATA= option is listed as optional.

image.png

Clicking on that DATA= link goes to this more detailed section:

image.png

Clicking on that Input Data Sets link goes to this comment:

 

Input Data Sets

Many Base SAS procedures require an input SAS data set. You specify the input SAS data set by using the DATA= option in the procedure statement, as in this example:
proc print data=emp;
If you omit the DATA= option, the procedure uses the value of the SAS system option _LAST_=. The default of _LAST_= is the most recently created SAS data set in the current SAS job or session. _LAST_= is described in detail in the SAS Data Set Options: Reference.

 

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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
  • 5 replies
  • 1047 views
  • 1 like
  • 4 in conversation