DATA Step, Macro, Functions and more

What does put variable-name=@ statement do?

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 76
Accepted Solution

What does put variable-name=@ statement do?

In the example given here: http://support.sas.com/kb/24/651.html, what does the following statement do?

 

  put month_name= @;

 


Accepted Solutions
Solution
‎03-02-2016 06:32 PM
Contributor
Posts: 39

Re: What does put variable-name=@ statement do?

The trailing @ in the put statement holds the pointer and stops is going to a new line. So in the case in the example in http://support.sas.com/kb/24/651.html the next 'put' statement is written to the same output line to keep all in a row.

 

This is probably best shown by example:

 

The original code and output is as follows:

 

data _null_;

  input date :mmddyy8.;

 

  /* Create a new variable */

  month_name=PUT(date,monname.);

  put month_name= @;

 

  /* or just format the date */

  put @25 date @35 date monname.;

datalines;

01/15/04

02/29/04

07/04/04

08/18/04

12/31/04

;

 

The output to the log is:

 

month_name=January      16085       January

month_name=February     16130      February

month_name=July         16256          July

month_name=August       16301        August

month_name=December     16436      December

 

 

If you remove the trailing '@' from the first 'put' statement using the code below, you'll see how the output differs:

 

data _null_;

  input date :mmddyy8.;

 

  /* Create a new variable */

  month_name=PUT(date,monname.);

  put month_name= ;

 

  /* or just format the date */

  put @25 date @35 date monname.;

datalines;

01/15/04

02/29/04

07/04/04

08/18/04

12/31/04

;

 

month_name=January

                        16085       January

month_name=February

                        16130      February

month_name=July

                        16256          July

month_name=August

                        16301        August

month_name=December

                        16436      December

 

The following will probably explain it better?

 

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

 

Does this help?

 

regards

 

 

David

 

View solution in original post


All Replies
Solution
‎03-02-2016 06:32 PM
Contributor
Posts: 39

Re: What does put variable-name=@ statement do?

The trailing @ in the put statement holds the pointer and stops is going to a new line. So in the case in the example in http://support.sas.com/kb/24/651.html the next 'put' statement is written to the same output line to keep all in a row.

 

This is probably best shown by example:

 

The original code and output is as follows:

 

data _null_;

  input date :mmddyy8.;

 

  /* Create a new variable */

  month_name=PUT(date,monname.);

  put month_name= @;

 

  /* or just format the date */

  put @25 date @35 date monname.;

datalines;

01/15/04

02/29/04

07/04/04

08/18/04

12/31/04

;

 

The output to the log is:

 

month_name=January      16085       January

month_name=February     16130      February

month_name=July         16256          July

month_name=August       16301        August

month_name=December     16436      December

 

 

If you remove the trailing '@' from the first 'put' statement using the code below, you'll see how the output differs:

 

data _null_;

  input date :mmddyy8.;

 

  /* Create a new variable */

  month_name=PUT(date,monname.);

  put month_name= ;

 

  /* or just format the date */

  put @25 date @35 date monname.;

datalines;

01/15/04

02/29/04

07/04/04

08/18/04

12/31/04

;

 

month_name=January

                        16085       January

month_name=February

                        16130      February

month_name=July

                        16256          July

month_name=August

                        16301        August

month_name=December

                        16436      December

 

The following will probably explain it better?

 

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

 

Does this help?

 

regards

 

 

David

 

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 201 views
  • 3 likes
  • 2 in conversation