Hi,
I have a dataset with multiple variables for different cohorts. The dataset contains date of birth variable, sex, race and vaccine dates from 3 follow-up periods and therefore three cohorts. I would like to consolidate the demographic variables for all subjects from the different cohorts in the dataset into one single demographic variable for sex, gender, dob, vaccine date, etc.
Note: some subjects belong to more than one cohort. They were re-enrolled for follow-up.
Edit: I added the remaining variables to the table. Race/ethnicity and gender are categorical variables.
Example of the dataset:
Studyid | cohort1_dob | cohort2_dob | cohort3_dob | Race/ethnicity cohort1 | Race/ethnicity cohort 2 | Race/ethnicity cohort 3 | Gender cohort 1 | Gender cohort 2 | Gender cohort 3 | cohort1_vaxdate | cohort2_vaxdate | cohort3_vaxdate |
001 | . | . | 12/31/1990 | . | . | 1 | . | . | 5 | . | . | 14/06/2005 |
002 | 10/05/1998 | . | . | 1 | . | . | 1 | . | . | 15/06/2004 | . | . |
003 | 02/01/1994 | . | 02/01/1994 | 2 | . | 2 | 3 | . | 3 | 23/07/2009 | . | 16/03/2021 |
004 | 03/04/1989 | 03/04/1989 | . | 1 | 1 | . | 1 | 1 | . | 16/05/2006 | 08/08/2013 | |
005 | . | 04/05/2009 | . | . | 2 | . | . | 1 | . | 14/04/2008 | ||
006 | 05/07/2008 | . | 05/07/2008 | 1 | . | 1 | 3 | . | 3 | 04/12/2012 | . | 17/06/2017 |
I don't see any of the variables you mention in the table you have posted, so please post the data in usable form and include all variables that are in the dataset. Merging variables is almost always a bad idea, because it will be more difficult to use the new variable to filter the data.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.