BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Reema
Fluorite | Level 6

Hi Everyone,

 

After trying the following codes:

data Enrolid_SD;
	Set S.MS_Enrolid;
	By enrolid svcdate;
	If first. enrolid then Index_Dt = Svcdate;
	format Index_Dt date9.;
run;

I am getting output like this: 

1

497201

02MAR2011

1928

02MAR2011

 

2

497201

08JUN2011

1928

.

  

3

497201

10OCT2011

1928

.

 

4

497201

10JAN2012

1928

.

  

5

581601

18JUN2009

1934

18JUN2009

 

6

581601

14DEC2009

1934

.

 

 

7

1203301

15MAR2011

1928

15MAR2011

 

8

1234801

20MAY2009

1939

20MAY2009

  

9

1257301

09FEB2012

1928

09FEB2012

 

But I want output like this i.e. I don't want any missing index_dt value, but I want the previous index_dt there.

 

1

497201

02MAR2011

1928

02MAR2011

 

2

497201

08JUN2011

1928

02MAR2011

 

3

497201

10OCT2011

1928

02MAR2011

 

4

497201

10JAN2012

1928

02MAR2011

 

5

581601

18JUN2009

1934

18JUN2009

 

6

581601

14DEC2009

1934

18JUN2009

 

7

1203301

15MAR2011

1928

15MAR2011

 

8

1234801

20MAY2009

1939

20MAY2009

 

9

1257301

09FEB2012

1928

09FEB2012

 

Someone please look into it and provide easy codes.

 

Thanks!

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Shmuel
Garnet | Level 18

Sorry - it shold be:

    RETAIN INDEX_DT;

View solution in original post

3 REPLIES 3
Shmuel
Garnet | Level 18

I have the feeling that you miss a line after the BY ...

    RETAIN SVCDATE;

Shmuel
Garnet | Level 18

Sorry - it shold be:

    RETAIN INDEX_DT;

Reema
Fluorite | Level 6
Thanks Shmuel.. but actually it must be:
retain index_dt; /* after by statement */

I have checked.

Please edit your comment, then I will mark it as a solution.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register 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.

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
  • 3 replies
  • 852 views
  • 2 likes
  • 2 in conversation