hi,
i want to eliminate w.d note from these calculations
data test1;
calc=77;
call symputx('calc',calc);
run;
data test;
input numb;
datalines;
77
58
;
data test2;
set test;
total=numb/&calc*100;
total2=PUT (total,4.1);
run;
i've tried to round total
data test2;
set test;
total=round(numb/&calc*100,4.1);
total2=PUT (total,4.1);
run;
and it doesnt print me w.d but... i have wrong results, sas shows me that (77/77*100,4.1)=98.4 instead of 100. I don't understand this.
thank you for your help
Hi @Jedrzej,
Just to add the explanations:
Here you are.
By the way, do not use a macro variable to merge a single number to all records in another dataset.
Use the "if _N_=1 then set" technique instead.
data test1; calc=77; run;
data test;
input numb;
datalines;
77
58
;
run;
data test2;
if _N_=1 then set test1;
set test;
total=numb/calc;
put total= percent15.5;
put total= percent10.0;
run;
Cheers,
Koen
Define total2 as char type with appropriate length:
For format 4.2 assign LENGTH TOTAL2 $7;
Hi @Jedrzej,
Just to add the explanations:
total=round(numb/&calc*100,4.1);
rounds to the nearest multiple of 4.1. The nearest multiple of 4.1 to 100 (100 is the value of numb/&calc*100) is 24*4.1=98.4
If you want to round to the nearest decimal place i.e. nearest tenth, you would want round(numb/&calc*100,0.1)
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.