BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
tomas-andriotti
Calcite | Level 5

Hello, 

i need help with coding a longitudinal dataset.

I want to exclude individuals from a long format dataset which have different levels of the covariate over time, i.e., if they present a hospital type observations in one occasion as PFF system and in one another as DIRECT system, they should be excluded. if on all occasions they are only PFF or only DIRECT they should stay in the dataset. Thus, I can only keep those who do not cross between systems over time. The covariate is binary, PFF/DIREC.

Look forward to hearing from you.

TA

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

Try something like:

 

proc sql;
create table want as
select * 
from have
group by patientID
having count(distinct hospitalType) <= 1;
quit;
PG

View solution in original post

2 REPLIES 2
PGStats
Opal | Level 21

Try something like:

 

proc sql;
create table want as
select * 
from have
group by patientID
having count(distinct hospitalType) <= 1;
quit;
PG
tomas-andriotti
Calcite | Level 5

thank you ! very helpful

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 2 replies
  • 742 views
  • 0 likes
  • 2 in conversation