BookmarkSubscribeRSS Feed
Quartz | Level 8

I have  a panel data with dates in columns and ID of a person in a row. I would like to create a table with ids, first occurence of X,Y or Z for each ID, date of first occurence of X,Y,Z and the prior cell observation or last cell with any observation of X,Y or Z. Do I use array for this? Please suggest.


I am using SAS 9.4 and SAS Enterprise guide 6.1.

Super User

Many users here don't want to download Excel files because of virus potential, others have such things blocked by security software. Also if you give us Excel we have to create a SAS data set and due to the non-existent constraints on Excel data cells the result we end up with may not have variables of the same type (numeric or character) and even values.


Instructions here: will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.


It works much better to show input and desired output directly in the post.


Instead of your excel spreadsheet, why not show us the layout of a couple of observations, and a layout of what you want?



The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets



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
  • 2 replies
  • 3 in conversation