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
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
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.
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
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.