BookmarkSubscribeRSS Feed
as_methodology
Fluorite | Level 6

Hello

 

I have an panel and each month I receive a list of all the persons that were in that panel in a that month.Each obeservation has variable indicating the year and month (yyyymm) as well as an ID. What I am trying to do is to generate a list of observations that have entered or left the panel in any given month.

 

I am very thankful for any ideas/suggestions.

 

 

 

 

3 REPLIES 3
SuryaKiran
Meteorite | Level 14

It all depends on the data you have. Please provide with some sample data.

Thanks,
Suryakiran
as_methodology
Fluorite | Level 6

Hi Suryakiran

 

Thanks for the reply. I don't know if this helps, but this is basically what I have for August 2018:

 

YEAR_MONTHIDCityMore Info
201808180764Eschen
201808332011Eschen
201808901917Eschen
201808849856Vaduz
201808430057Vaduz
201808721939Schaan
20180878890Schaan
201808234806Planken

 

What I tried so far is to create an extra column with month t-1:

YEAR_MONTHYEAR_MONTH_1IDCityMore Info
201808201807180764Eschen
201808201807332011Eschen
201808201807901917Eschen
201808201807849856Vaduz

 

And then using catx to generate an unique month-person identifier for month t and month t-1.

YEAR_MONTHYEAR_MONTH_1IDID_MONTHID_MONTH_1CityMore Info
201808201807180764180764x201808180764x201807Eschen
201808201807332011332011x201808332011x201807Eschen
201808201807901917901917x201808901917x201807Eschen
201808201807849856849856x201808849856x201807Vaduz

 

Then using proc sql to join it up with itself


PROC SQL;
   CREATE TABLE WORK.TEST AS
   SELECT *,
           t2.ONE
      FROM WORK.TEST t1
           LEFT JOIN WORK.TEST t2 ON (t1.YEAR_MONTH = t2.YEAR_MONTH_1);
QUIT;

 

where ONE is a column containing only a 1 for each observation. The idea being that maches will result in a 1, whereas if there was no match it will create a missing value. Technically, it should work, but it hasn't yet. So I was also wonderig whether there would be an easier approach.

 

Thanks a lot already, Simon

as_methodology
Fluorite | Level 6

Update: It works the way I mentioned in my previous post. It's a little tedious but it works.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 3 replies
  • 667 views
  • 0 likes
  • 2 in conversation