Help using Base SAS procedures

Trouble with parentheses

Reply
N/A
Posts: 1

Trouble with parentheses

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?


Super User
Posts: 5,498

Re: Trouble with parentheses

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.

Ask a Question
Discussion stats
  • 1 reply
  • 157 views
  • 0 likes
  • 2 in conversation