- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
RTM
Syntax
Required Arguments
- source
- identifies the constant, variable, or expression whose value you want to reformat. The sourceargument can be character or numeric.
- format.
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. Restriction:The format. must be of the same type as the source, either character or numeric. That is, if the source is character, the format name must begin with a dollar sign, but if the source is numeric, the format name must not begin with a dollar sign.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
RTM
Syntax
Required Arguments
- source
- identifies the constant, variable, or expression whose value you want to reformat. The sourceargument can be character or numeric.
- format.
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. Restriction:The format. must be of the same type as the source, either character or numeric. That is, if the source is character, the format name must begin with a dollar sign, but if the source is numeric, the format name must not begin with a dollar sign.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Why are you converting this perfectly good numeric variable to character anyway. I can see no avantage to that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Bcos i want to categorize based on this variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You don't need to convert to character to use is as categorical variable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
No.
Doesn't Proc report allow you to justify the data, left/right/center?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You don't have to. Do you know what -L does?