- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I have a dataset with some accounts and every account may have more than one observation in the data.
Assuming a scenarion, if one of the account has 10 observations and every observation has a different stat_code which is one of the variables along with stat_dt
What i want to do is to go through the first entry till the last entry of the duplicate accounts and then apply a condition
on stat_code, something like if substr(stat_code, 4,1) = 'S' and every time it finds that between the first and the last observation, it outputs that entry into a seperate dataset.
Will appreciate some direction and help!
--Tej
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I don't see anything to indicate the need for something besides a simple filter.
SAS loops through each one in the dataset by default, and you can implement BY group processing if it's needed.
See the tutorial here in how to filter
http://support.sas.com/training/tutorial/studio/filter-tables.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Please provide sample (in machine readable format) input and expected output data, for us to work on.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Here is a sample input. I want to go through each and every account as you see there are duplicate and search for where substr(status_code,4,1) = 'L' and where ever it finds that it outputs that record.
Account | Status Code | Date |
11112 | XYZS | 10th Jan 2011 |
11112 | HGJL | 11th Jan 2011 |
11112 | FTYJ | 12th Jan 2011 |
11112 | LKIL | 13th Jan 2011 |
234322 | PLKS | 6th June 2016 |
234322 | RTYZ | 7th June 2016 |
234322 | KJLL | 8th June 2016 |
234322 | IUYL | 9th June 2016 |
234322 | RTYZ | 10th June 2016 |
234322 | RTYZ | 11th June 2016 |
234322 | RTYZ | 12th June 2016 |
Output should look like below as it output recoed whereever it finds that string
11112 | HGJL | 11th Jan 2011 |
11112 | LKIL | 13th Jan 2011 |
234322 | KJLL | 8th June 2016 |
234322 | IUYL | 9th June 2016 |
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Did you try anything? This should be really straight forward, especially after the video example.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I don't see anything to indicate the need for something besides a simple filter.
SAS loops through each one in the dataset by default, and you can implement BY group processing if it's needed.
See the tutorial here in how to filter
http://support.sas.com/training/tutorial/studio/filter-tables.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
BY processing usually means there is something special done with each level or group, or combination of levels, of the By variable(s).
You do not show anything that is dependent on a group of values.
I could add a by statement to the datastep but it wouldn't add any value. If you wanted to know something like the order number within the account value then that could use by processing.
If there is something else other than the data shown and the rule and desired results then there may be some value to adding by group processing.