BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
noling
SAS Employee

You're welcome! I know the VBA to SAS transition isn't 1-1.


Register today and join us virtually on June 16!
sasglobalforum.com | #SASGF

View now: on-demand content for SAS users

gossetm3
Calcite | Level 5
When I clear out the values if Open, can I also set another field called OpenDt to the book date and keep it regardless of the other status changes for that Claimant/CovCd combo?
noling
SAS Employee

Sure you can! You'll want to add your new OpenDt field to the RETAIN statement. I suspect you'll also want to clear out that value for each new ClaimNumber. If you don't clear out OpenDt like you do for CloseDt and reopenDT, it will just persist

 

You'll want to consider how to handle 2 'Open's in a row like you have in rows 38 and 39. If you only want the first one, then you'll need to use some first-DOT processing.


Register today and join us virtually on June 16!
sasglobalforum.com | #SASGF

View now: on-demand content for SAS users

gossetm3
Calcite | Level 5

So yes, I would need to do some first logic because I want the first open date to carry until the last occurrence of that claimant/coverage combo within that claim.  I added that and it appears to be working.

 

Thank you.

Tom
Super User Tom
Super User

I don't totally follow your logic and since you haven't posted data in a usable format (xslx doesn't really count) not going to play with it.

 

Note that when you have multiple variables in the BY statement the effect is nested.  So if you use BY A B C.  The flag FIRST.B is the true in the first observation for a set of observations that have the same value of B within the larger set of observations that have the current value of A also.  Another way to think about it is that when you start a new A group then you also start a new B and C group.

 

To keep track of the first occurrence of an event within a group you can use a flag that tells you whether the event has occurred yet.  If you are setting a variable to missing then setting it to non-missing when the event occurs then you might just be able to use that same variable as the flag.  So to save the current date into a new variable named first_date when a particular status is found you could use code like this:

if status='LOOKING FOR THIS' and missing(first_date) then first_date = current_date;

Or perhaps more simply:

if status='LOOKING FOR THIS'  then first_date = coalesce(first_date,current_date);

Watch out for observations that meet your status criteria but have missing values of the variable you want to capture. What do you want to do in that case? Should the new variable be left missing?  Should we keep looking for another observation with that status that doesn't have a missing value for the other variable?

 

To further expand your flexibility google the DOW loop concept in SAS data step code.  https://www.google.com/search?q=%40sas.com+dow+loop

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 19 replies
  • 5173 views
  • 0 likes
  • 5 in conversation