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:
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: