Combine Multiple Variables in SAS

Reply
Regular Contributor
Posts: 150

Combine Multiple Variables in SAS

I am working on a short retention calendar for a study. I have 5 visits and 4 identical variables. The Variables are set up like this:

v2status-v5status

1=interview completed

2=Due for Interview

3=Not due for interview

4=30 days past due

5=3 months past due

Basically what I want to do is create a new variable that combines all of the variables to show which interview a participant is currently due for with the following categories:

1=12 month

2=18 month

3=24 month

4=completed study

I started writing the code in its most simple form, the problem is there is a combination of possible outcomes because a participant would have missed visit 2 but completed visit 3  and missed visit 4, etc..Participants can no longer complete visit 2. Give the original variable v2status-v5status, is there an easy way to figure out all possible combinations of variables so I can write the code to take them into account? The code I have now only takes into account perfect retention and takes into account about half of the actual data. Any help is greatly appreciated as I would prefer no to write 100 lines of code for this one variable and all different combinations.

if v2status in (1) and v3status in (1) and v4status in (1) and v5status in (1) then visit_num=5; ***Completed the study;

else if v5status in (1) then visit_num=5;***Completed the study;

else if v2status in (1) and v3status in (1) and v4status in (1) and v5status in (2,4,5) then visit_num=3; ***Due for 24 month visit;

else if v2status in (1) and v3status in (1) and v4status in (2,4,5)  then visit_num=2; **Due for 18 month visit;

else if v2status in (1) and v3status in (2,4,5)   then visit_num=1; ***Due for 12 month visit;

Super User
Posts: 17,784

Re: Combine Multiple Variables in SAS

Wouldn't you only be interested in the last non-missing data point then?

Can you post some sample data with expected output?

Regular Contributor
Posts: 150

Re: Combine Multiple Variables in SAS

None of them will have missing data because these variables are figured out based on the time since their baseline visit and specific dates.

I am attaching some data that I created that is similar to what I am looking at. I can't post actual data because of IRB protocols, etc...I wasn't sure how to post an excel file so the data is below

The expected output would be a variable that tells me who is currently due and for what visit. I will use ODS output and proc print to create a listing in word. I hope this helps clarify.

IDv3statusv4statusv5statusv2status
A235555
A245555
A255545
A265545
A275545
A285545
A295545
A555525
A565525
A575525
A585525
A595525
A795535
A805535
A815535
A825535
A835535
A845435
A855435
A865435
A875435
A885435
A895435
A905435
A915435
A925435
A1764231
A1772335
A1784231
A1792335
A1804231
A1812335
A1822335
A1832335
A1841441
A1851431
A1861421
A1872335
A1882335
A1892335
A1912335
A1922335
A1934331
A1943334
A1953334
A1961151
A1971151
A1981431
A1994331
A4781111
A4791111
A4801111
A4811111
A4821111
A4834111
A4844114
A4854414
A4864111
A4871111
A4884414
A4891111
A4901111
A4911111
A4921114
Super User
Posts: 17,784

Re: Combine Multiple Variables in SAS

Expected output? I'd rather have only 5 or 6 lines of data with the expected output.

Regular Contributor
Posts: 150

Re: Combine Multiple Variables in SAS

Ok. Here is the expected output and below is the sample data that would produce this expected output. Let me know if you need more information.

Expected output.

ID            Visit Due

A188     Visit 3

A189     Visit 5

A191     Visit 4

A192     Visit 3

A193     Visit 3

A194     Visit 3

A195     Visit 4

ID                                v3statusv4statusv5statusv2status
A1882335
A1895525
A1915235
A1922335
A1934331
A1943334
A1955434
Super User
Posts: 9,671

Re: Combine Multiple Variables in SAS

Can you explain how you get Visit Due ?

Ask a Question
Discussion stats
  • 5 replies
  • 202 views
  • 0 likes
  • 3 in conversation