turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- SAS Procedures
- /
- Trouble with parentheses

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

06-23-2014 01:26 PM

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?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

06-23-2014 02:21 PM

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.