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

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 1184 views
  • 0 likes
  • 4 in conversation