Hello,
I was given SAS code but my work is all STATA (version 17). I've never used SAS before and am new to STATA so I am struggling to find the commands for this SAS code:
by xid year month;
if first.xid then count=0;
count+1;
run;
What I am trying to do is assign a "count" value for each case/month that indicates that case's/month's order within all the cases/months for that participant.
For example:
xid year month count
1 2020 9 1
1 2020 10 2
1 2020 11 3
1 2020 12 4
1 2021 1 5
1 2021 2 6
2 2020 8 1
2 2020 9 2
2 2020 10 3
I have about 3990 xid, 90k obs, and on average 31 month of data per xid. Everyone started at different times so I will be using this count variable to create a new variable such as if count 1-12= Year1, count 13-24=Year2...etc.
Thanks in advance!
I was given SAS code but my work is all STATA (version 17). I've never used SAS before and am new to STATA so I am struggling to find the commands for this SAS code:
by xid year month;
if first.xid then count=0;
count+1;
run;
What I am trying to do is assign a "count" value for each case/month that indicates that case's/month's order within all the cases/months for that participant.
For example:
xid year month count
1 2020 9 1
1 2020 10 2
1 2020 11 3
1 2020 12 4
1 2021 1 5
1 2021 2 6
2 2020 8 1
2 2020 9 2
2 2020 10 3
I have about 3990 xid, 90k obs, and on average 31 month of data per xid. Everyone started at different times so I will be using this count variable to create a new variable such as if count 1-12= Year1, count 13-24=Year2...etc.
Thanks in advance!
Comment