Hi,
could someone explain to me why we have to write the format and -l while we are converting Numeric to charecter(using PUT) in the below example??
HAVE
ID SCORES(numeric)
10 .
11 0
12 3
13 1
14 0
15 .
16 .
data want;
set have;
length _scores $ 20;
_scores=put(scores,20. -l );
run;
Thanks
RTM
contains the SAS format that you want applied to the value that is specified in the source. This argument must be the name of a format with a period and optional width and decimal specifications, not a character constant, variable, or expression. By default, if the source is numeric, the resulting string is right aligned, and if the source is character, the result is left aligned. To override the default alignment, you can add an alignment specification to a format:
-L | left aligns the value. |
-C | centers the value. |
-R | right aligns the value. |
RTM
contains the SAS format that you want applied to the value that is specified in the source. This argument must be the name of a format with a period and optional width and decimal specifications, not a character constant, variable, or expression. By default, if the source is numeric, the resulting string is right aligned, and if the source is character, the result is left aligned. To override the default alignment, you can add an alignment specification to a format:
-L | left aligns the value. |
-C | centers the value. |
-R | right aligns the value. |
Hi ,
Thanks for the responses...
I was also wondering : the _scores variable is charecter in the WANT dataset and still has the dots instead of SPACES!!!!
ALSO does it matter during analysis for either alligning it Left or center or right?????
Regards
Why are you converting this perfectly good numeric variable to character anyway. I can see no avantage to that.
Bcos i want to categorize based on this variable
You don't need to convert to character to use is as categorical variable.
Interesting. I will also check my code again to verify if the numeric variable can also be grouped in the REPORT
May be in this case it is converted to charecter only because of the report presentation .to show it to the left instead of the right side.
Do u agree??
Thanks
No.
Doesn't Proc report allow you to justify the data, left/right/center?
You don't have to. Do you know what -L does?
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.