BookmarkSubscribeRSS Feed
Cdot
Fluorite | Level 6

Hi all,

I have a data set with 2 observations per person, in long format, and I want to select people of a certain age at T1 and a certain place of residence at T1, plus their T2 record, where residence may have changed. I can figure out how to select all the T1 records I want, but not the associated T2 record – any help would be much appreciated!

6 REPLIES 6
pearsoninst
Pyrite | Level 9
Can you provide an example dataset?
Cdot
Fluorite | Level 6

Sure

ID Household IDyear of interviewAge at interviewresidenceetcetc
112004461  
112006481  
212004671  
212006692  
322004783  
322006793  
432004671  
432006892  
Reeza
Super User
Once you have the T1 records, you can use a SQL step to get all records from the original table.
Assuming your source data is called HAVE and the table with records selected is called T1_Selected you can do the following:

proc sql;
create table want as
select *
from have
where ID in (select ID from T1_Selected);
quit;
Cdot
Fluorite | Level 6

Another very basic question - how do I create the first table?

Cdot
Fluorite | Level 6

And, each participant is identified by both a personal ID and a household ID.

Thank you!

Patrick
Opal | Level 21

"how do I create the first table?"

The "have" table? So you don't have your table already in SAS? In what format is your source data (excel, csv,...?). What SAS client are you using (SAS EG, SAS Studio?)

 

"And, each participant is identified by both a personal ID and a household ID."

The data you posted looks like a person is fully identified by "personal ID". "household ID" appears to be what it says: Grouping persons together into households.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

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