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

The code example in SAS support documentation Zw.d SAS Documentation doesn't seem to do what they say it should do. 

data one;

num=1350;

put num z8.; run;

When I run this, I get 

zwd.jpg

Documentation says I should see:

zwd1.jpg

 I don't get the leading zeros. 

 

Advice would be appreciated. 


Thanks

David

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

You only use the format in the PUT statement, so it only has effect on the output in the SAS log. To make it have an effect on the column as stored in the dataset (and visible in the OUTPUT DATA tab), you need to use a FORMAT statement:

data one;
num=1350;
format num z8.;
run;

 

View solution in original post

3 REPLIES 3
Kurt_Bremser
Super User

You only use the format in the PUT statement, so it only has effect on the output in the SAS log. To make it have an effect on the column as stored in the dataset (and visible in the OUTPUT DATA tab), you need to use a FORMAT statement:

data one;
num=1350;
format num z8.;
run;

 

DavidBrown
Obsidian | Level 7

@Kurt_Bremser Thanks so much. I wish they would explain that in the documentation. Coming from R, Python, and SQL, I find SAS documentation leaves much to be desired. But, thanks again, and I appreciate the reply. 

Kurt_Bremser
Super User

Why do you find that SAS documentation leaves much to be desired?

From the documentation of the PUT Statement:

PUT Statement

Writes lines to the SAS log, to the SAS output window, or to an external location that is specified in the most recent FILE statement.

 

 

(Emphasis by me)

 

What I do mean: because of the sheer mass of all things SAS, the documentation is awe-inspring because of its sheer size. It takes some time to get a feel for where to look. Whenever you are puzzled by the behaviour of a piece of code, look up the documentation for all elements used, and also do not forget that there might be other things having an influence that are not part of the code, like the setting of system options or the current state of the ODS.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 3 replies
  • 816 views
  • 4 likes
  • 2 in conversation