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

Hi Everyone,

 

I'm trying to carry a visit date across all rows of each participant ID, to create a start date column. I've used the below code to carry values across IDs in other coding, but now it just keeps telling me that _id is uninitialized. Is there something I'm missing? Is there a better way to do this?

 

Code:

data TOSStart(drop=_:);
do until (last.id);
set toscount;
by id;
if id > _id then do;
_Start = Start;
end;
end;
do until (last.id);
set toscount;
by id;
Start = _Start;
output;
end;
run;

 

Have this:

IDStart
11/1/2022
1 
1 
1 
43/5/2022
4 
4 
62/8/2022
6 
6 
6 
6 
6 
6 

 

Want this:

IDStart
11/1/2022
11/1/2022
11/1/2022
11/1/2022
43/5/2022
43/5/2022
43/5/2022
62/8/2022
62/8/2022
62/8/2022
62/8/2022
62/8/2022
62/8/2022
62/8/2022

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
2 REPLIES 2
Kurt_Bremser
Super User

Do this:

data TOSStart (drop=_:);
set toscount (rename=(start=_start));
by id;
retain start;
format start mmddyy10.;
if first.id then start = _start;
run;
EpiNovice
Calcite | Level 5
Worked like a charm, thanks!!

Catch up on SAS Innovate 2026

Nearly 200 sessions are now available on demand with the SAS Innovate Digital Pass.

Explore Now →
How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1368 views
  • 0 likes
  • 2 in conversation