BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mduarte
Quartz | Level 8

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

 

  put month_name= @;

 

1 ACCEPTED SOLUTION

Accepted Solutions
moorsd
Obsidian | Level 7

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

1 REPLY 1
moorsd
Obsidian | Level 7

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

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 1 reply
  • 1079 views
  • 3 likes
  • 2 in conversation