BookmarkSubscribeRSS Feed
nicopark
Calcite | Level 5

Hey all,

I'm new and am stuck on how to subtract one column from another - both are numeric and have a year (ex. 1994) as well as a number in parentheses matching the year (ex. 94). So each value looks like "(94) 1994", or in another example "(81) 1981". When I subtract the two values from another, I get some funky answers (negative and exponential). What's a good way of getting rid of one of the values for a large dataset and completing the subtraction task?


1 REPLY 1
Astounding
PROC Star

The first step begins with finding out what the variables actually contain.  Taking your word for it that the variables are actually numeric, the only way that parentheses print is because the variables are printed with a format.  So you have to remove the format and print a few actual values to get some idea of what the variables contain.  Luckily, that is easy:

proc print data=have (obs=20);

var column1 column2;

format column1 column2;

run;

After that, it's possible that you will have enough information to perform the subtraction.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 1001 views
  • 0 likes
  • 2 in conversation