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;
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.