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:
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.