Visit mapping:
how do I do visit mapping for the below example:
VISIT |
VISITNUM |
VISITDY |
|||||
SCREENING |
1 |
-14 |
|||||
DAY 1 |
2 |
1 |
|||||
DAY 1 REPEAT |
2.01 |
||||||
UNSCHEDULED (different day, chronological order) |
2.01 |
||||||
UNSCHEDULED REPEAT |
2.02 |
||||||
UNSCHEDULED (different day, chronological order) |
2.03 |
||||||
DAY 21 |
6 |
21 |
|||||
Early Term |
7 |
||||||
UNSCHEDULED |
VISITNUM increases by .01 in chronological order (e.g. 2.01, 2.02) |
||||||
[VISIT] REPEAT |
VISITNUM increases by .01 in chronological order (e.g. 2.01, 2.02) |
||||||
|
I think you need to be more cler about the data you're starting with, and the result that you need. For a report? For further analysis? Share any code that you've already tried.
Hi Chris,
Iam trying to map an unscheduled visit happens between visit 1 and 2 then visit number for that unscheduled visit should be 1.01 and if thereare 2 unscheduled visits, visi number should be 1.01 and 1.02 and so on, the following is sample data, visit number should be derived for an EG dataset:
subject_id1 visit visit_number
1 screening 1
1 day1 2
1 unscheduled 2.01
1 unscheduled 2.02
code:
data vis;
set ecg;
by subject_id1;
retain lstvisit lstunsched;
if first.subject_id1 then do;
lstvisit=_visitnum;
lstunsched =0;
end;
else if visit = "unsceduled" then do;
lstunsched=lstunsched+0.01;
_visitnum=lstvisit+lstunsched;
end;
else lstvisit = _visitnum;
run;
@siri6 OK. Is your code working or do you still need assistance?
It is not working, still need assistance, thanks in advance
@siri6 wrote:
It is not working, still need assistance, thanks in advance
Than please post input an desired output.
I took a coupl of guesses about how it should work, but hopefully this will move the yardsticks.
Tom
data vis;
set ecg;
by subject_id1;
retain holdvisit holdunsched;
drop holdvisit holdunsched;
if first.subject_id1 then do;
holdvisit=0;
holdunsched =0;
end;
if visit ^= "unscheduled"
then do;
holdvisit = holdvisit + 1;
visit_number = holdvisit;
end;
else do;
holdunsched = holdunsched + .01;
visit_number = holdvisit + holdunsched;
end;
run;
Hi All, sorry for the delay in posting the input and desired output,please give me reply, thank you all in advance.
Example data:
INPUT data:
Id vis date tpt vis_num
101 visit1 22dec2010 1h 1
101 visit1 22dec2010 1h 1
102 visit1 23dec2010 1h 1
102 visit1 23dec2010 1h 1
103 visit1 25dec2010 1h 1
103 visit2 26dec2010 3h 2
101 visit2 28dec2010 3h 2
102 visit2 28dec2010 3h 2
102 visit2 28dec2010 3h 2
102 visit2 28dec2010 3h 2
102 visit2 28dec2010 3h 2
101 unsc 30dec2010 2h
102 unsc 29dec2010 4h
101 unsc 31dec2010 5h
102 unsc 30dec2010 2h
102 unsc 30dec2010 1h
103 unsc 29dec2010 2h
103 unsc 25dec2010 3h
103 unsc 28dec2010 4h
103 unsc 29dec2010 2h
in output data the variables I need are visit and visit_num
OUTPUT data:
Id vis date tpt vis_num visit visi_num
101 visit1 22dec2010 1h 1 visit1 1
101 visit1 22dec2010 2h 1 visit1 repeat 1.1
102 visit1 23dec2010 1h 1 visit1 1
102 visit1 23dec2010 2h 1 visit1 repeat 1.1
103 visit1 25dec2010 1h 1 visit1 1
103 visit2 26dec2010 3h 2 visit2 2
101 visit2 28dec2010 3h 2 visit2 2
102 visit2 28dec2010 3h 2 visit2 2
102 visit2 28dec2010 2h 2 visit2 repeat 2.1
102 visit2 28dec2010 3h 2 visit2 repeat 2.2
102 visit2 28dec2010 4h 2 visit2 repeat 2.3
101 unsc 30dec2010 2h unsc 2.1
102 unsc 29dec2010 4h unsc 2.2
101 unsc 31dec2010 5h unsc 2.3
102 unsc 30dec2010 1h unsc 2.4
102 unsc 30dec2010 2h unsc repeat 2.5
103 unsc 29dec2010 2h unsc 2.6
103 unsc 25dec2010 3h unsc 2.7
103 unsc 28dec2010 4h unsc 2.8
103 unsc 29dec2010 6h unsc repeat 2.9
(Explanation:
In case repeat visits: Any scheduled visit that has a Repeat (duplicate visit name) regardless of collection date would be provided as [VISIT] REPEAT. Therefore visit1 REPEAT for example.
In case unscheduled visits:
UNS on 01Sep2017 following Visit 2 = UNSCHEDULED with VISITNUM 2.01 Second UNS on 01Sep2017 = UNSCHEDULED REPEAT with VISITNUM 2.02
First UNS on a different date eg 02Sep2017 = UNSCHEDULED 2.03 Second UNS on different date = UNSCHEDULED REPEAT 2.04)
Could anyone please reply to the issue, thank you
Please please could anyone look into it and help me out, I explained how did I need the outcome, Thanks
I think that @TomKari already provided you with a good start, though you'll probably need to adapt it a bit. The approach checks for visits beyond the first visit and numbers them accordingly.
(Note: the contributors on this forum are happy to provide guidance and examples, but I hope you're not relyng on this for a complete solution to homework or a mission-critical business problem.)
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!
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.