I have the following dataset:
Subject Score
1 3.432
2 4.83455
3 6.8333
4 14.834
and i want:
Subject Score Score_round
1 3.432 3
2 4.83455 5
3 6.8333 7
4 14.234 14
So far I've only found (but only as an output):
data new;
format score 9.0;
set old;
run;
I ultimately want a new variable created in the dataset called score_round (from the score variable)
data have;
input Subject Score ;
cards;
1 3.432
2 4.83455
3 6.8333
4 14.834
5 14.234
;
data want;
set have;
score_round=round(score);
run;
did you try the round function?
score_round=round(score);
data have;
input Subject Score ;
cards;
1 3.432
2 4.83455
3 6.8333
4 14.834
5 14.234
;
data want;
set have;
score_round=round(score);
run;
did you try the round function?
score_round=round(score);
thank you!! thought it was gonna be something more complicated 🙂
Although you can create a new variable that is the rounded value, perhaps you really want a format to show the rounded value rather than a new variable? There's good reasons to do things your way, and there's good reasons to NOT do things your way. It depends.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.