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)
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.