BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
BhararaTej
Fluorite | Level 6

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

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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

View solution in original post

6 REPLIES 6
PGStats
Opal | Level 21

Please provide sample (in machine readable format) input and expected output data, for us to work on.

PG
BhararaTej
Fluorite | Level 6

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.

 

AccountStatus CodeDate
11112XYZS10th Jan 2011
11112HGJL11th Jan 2011
11112FTYJ12th Jan 2011
11112LKIL13th Jan 2011
234322PLKS6th June 2016
234322RTYZ7th June 2016
234322KJLL8th June 2016
234322IUYL9th June 2016
234322RTYZ10th June 2016
234322RTYZ11th June 2016
234322RTYZ12th June 2016

 

 

Output should look like below as it output recoed whereever it finds that string

 

11112HGJL11th Jan 2011
11112LKIL13th Jan 2011
234322KJLL8th June 2016
234322IUYL9th June 2016
Reeza
Super User

Did you try anything? This should be really straight forward, especially after the video example.

Reeza
Super User

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

BhararaTej
Fluorite | Level 6
I know i can do the where clause but I am also looking to figure out a way to do this by "by processing"
ballardw
Super User

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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 1016 views
  • 0 likes
  • 4 in conversation