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

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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