Hi, in one of the numeric column of my dataset, I have 3 digits and 4 digits number.
I want to remove the last digit if the number have 4 digit, for example:
No Score
1 789
2 673
3 6470
4 783
5 7280
6 785
I want the 6470 to become 647 and 7280 to become 728, how should I do that with SAS programming?
This should do it:
if score >= 1000 then score = int(score/10);
Or take a quick detour to character:
data want;
set have;
score = input(substr(put(score,4.-l),1,3),3.);
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.