SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

selecting cases

Reply
Occasional Contributor
Posts: 5

selecting cases

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!

Frequent Contributor
Posts: 108

Re: selecting cases

Can you provide an example dataset?
Occasional Contributor
Posts: 5

Re: selecting cases

Posted in reply to pearsoninst

Sure

ID Household IDyear of interviewAge at interviewresidenceetcetc
112004461  
112006481  
212004671  
212006692  
322004783  
322006793  
432004671  
432006892  
Super User
Posts: 19,851

Re: selecting cases

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;
Occasional Contributor
Posts: 5

Re: selecting cases

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

Occasional Contributor
Posts: 5

Re: selecting cases

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

Thank you!

Respected Advisor
Posts: 4,173

Re: selecting cases

"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.

Ask a Question
Discussion stats
  • 6 replies
  • 363 views
  • 0 likes
  • 4 in conversation