BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
nwang5
Obsidian | Level 7

I tried to get the follow_up year of my dataset. This survey was conducted every two years. Is there any code that works for this? Thanks!

 

                                     Obs    ID    lle9    lle10   lle11   lle12   lle13   lle14      expect_results

                                     1      1      .       0       0       0       1       .                   6
                                     2      2      0       0       0       .       .       0                   10
                                     3      3      0       .       .       0       .       .                   6
                                     4      4      .       0       1       1       1       1                   8
                                     5      5      .       .       0       .       1       4                   6
                                     6      6      0       .       1       .       .       2                   10

 

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Hello @nwang5,

 

Try this:

data want;
set have;
if n(of lle:) then
   n_FU_years=2*(7-whichn(coalesce(of lle14-lle9), of lle14-lle9)
                  -whichn(coalesce(of lle9-lle14), of lle9-lle14));
run;

If it doesn't work for your real data, then I agree with ballardw that we might need to go through lots of details.

View solution in original post

3 REPLIES 3
ballardw
Super User

You have to walk us through the logic of how you get 6 or 10 or 8 or whatever. Probably in lots of details.

 

Especially since I see nothing there that is obviously a "year" to calculate what a "follow_up" year may be.

FreelanceReinh
Jade | Level 19

Hello @nwang5,

 

Try this:

data want;
set have;
if n(of lle:) then
   n_FU_years=2*(7-whichn(coalesce(of lle14-lle9), of lle14-lle9)
                  -whichn(coalesce(of lle9-lle14), of lle9-lle14));
run;

If it doesn't work for your real data, then I agree with ballardw that we might need to go through lots of details.

nwang5
Obsidian | Level 7
It works! Thank you so much!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 320 views
  • 1 like
  • 3 in conversation