BookmarkSubscribeRSS Feed
SDasari2
Calcite | Level 5

Attached is the file with the data i have and the desired output i am looking for.

 

Please help!

6 REPLIES 6
ballardw
Super User

And what are the rules for creating the LAG_EFF and LAG_TERM variables? I don't actuall see any difference between TERM_DATE and LAG_TERM Shown. And the rules for selecting the values to keep in the output?

 

And if your "dates" are such then I would suggest dropping the completely useless time portion since ever single value you show is 00:00:00. Easily done with the DATEPART function.

SDasari2
Calcite | Level 5

Sorry, for not being clear. The lag_term is same as the term date. I done need it. I just need the below output in SAS. Just put that in excel so that it is clear.

 

SDasari2
Calcite | Level 5
proc sort data=MEMBER_ADDRESS;
by SEQ_MEMB_ID ADDRESS_TYPE EFFECTIVE_DATE ADDRESS_LINE_1 ;run;

data MEMBER_ADDRESS1;
set MEMBER_ADDRESS;
by SEQ_MEMB_ID ADDRESS_TYPE EFFECTIVE_DATE ADDRESS_LINE_1;
   
retain LAG_EFF;

if FIRST.ADDRESS_LINE_1 then do;
LAG_EFF=EFFECTIVE_DATE;
end;

if LAST.ADDRESS_LINE_1 then do;
output;
end;

format LAG_EFF datetime20.; 
run;

This is the code, i am using. But i am not getting the desired output (want :Last table) as mentioned in the attached excel. Sorry for not being clear initially

ballardw
Super User

@SDasari2 wrote:

This is the code, i am using. But i am not getting the desired output (want :Last table) as mentioned in the attached excel. Sorry for not being clear initially


You should show the incorrect result your are getting FOR the example data shown only.

 

One might guess that your sort is grouping more values than you expect.

SDasari2
Calcite | Level 5

Attached file has the output i am getting. The last set of values. I dropped the Phone Number and County.

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 925 views
  • 0 likes
  • 3 in conversation