I have data like below
data a;
input x;
cards;
1234
54
0.005
0.634
run;
I want output as below
1234
54
0.00
0.63
Can anyone please suggest me
Define "output".
If you want this kind of behavior in a dataset, you need to create a custom format with a function.
If you want it in a report, consider proc report and a computed column.
Define "output".
If you want this kind of behavior in a dataset, you need to create a custom format with a function.
If you want it in a report, consider proc report and a computed column.
I want in data set, can you please write how to write custom format with function
Thanks for your reply
See here:
proc fcmp outlib=work.functions.smd;
function myfunc (arg) $;
if int(arg) = arg
then out = left(put(arg,best18.));
else out = left(put(arg,18.2));
return(out);
endsub;
run;
options cmplib=work.functions;
proc format;
value myfmt (default=18) other=[myfunc()];
run;
data a;
input x;
format x myfmt.;
y = put(x,myfmt.);
cards;
1234
54
0.005
0.634
;
Relevant parts of the documentation:
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.