Hi all,
i've a dataset like given bellow
N_ | 36 | 36 | 36 |
Mt_ | 9581.1728 | 9791.5262 | 1366.1106 |
S_D | 2965.8626 | 2982.0749 | 398.3543 |
Now i need to give decimal places for the variables what if other variables contain more decimal places how to find out that .i had tried many things like format, length and etc. but it didn't work well.
is it really possible? if so, can anyone tell me how?
Thanks in advance
You dont have a dataset like that, you can't have 36 as a variable name, nor can you have multiple of the same variable. Please post test data in the form of a datastep in future:
As such I can only speak generally in that:
data want; have=9581.1728; want=lenthn(scan(put(have,best.),2,".")); run;
So I take the second word from the number after putting it to text, delimited by ., then lengthn() to get how many characters.
You dont have a dataset like that, you can't have 36 as a variable name, nor can you have multiple of the same variable. Please post test data in the form of a datastep in future:
As such I can only speak generally in that:
data want; have=9581.1728; want=lenthn(scan(put(have,best.),2,".")); run;
So I take the second word from the number after putting it to text, delimited by ., then lengthn() to get how many characters.
try this
data test;
input amount 8.;
cards;
9581.1728
398.3543
12.12
1.12
;
run;
data want;
set test;
char=compress(amount||"","");
len=length(char);
dot=indexc(char,".");
before=dot-1;
after=len-dot;
run;
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.