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

 

Hello,

I have an id variable  (survey_unique_id) that, for some, does not  "increment by 1(up to 2056)" for a portion of observations. I want to keep the first observation "50001" and retain the vaue+1 for each observation that follows and continue this procedure until "52056".

 

I was able to create a new dataset just containing observations where "id" with 50001 only was available, without losing information of importance. 

 

Hope this is clear.

 

Thanks.

 

(Original dataset)

 

 

help (2).png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Example of what I had in mind for the variable (survey_unique_id) to look like.

5001

5002

5003

5004

5005

5006

5007

5008

5009

5010

etc...

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

50001 or 5001?

 

data want;
retain count 5001;
set have;
if id > 2056 then do;
  id = count;
  count = count + 1;
  end;
drop count;
run;
PG

View solution in original post

3 REPLIES 3
Reeza
Super User
Just replace it with a new one?

Retain NEWID 5000;

NEWID+1;
PGStats
Opal | Level 21

50001 or 5001?

 

data want;
retain count 5001;
set have;
if id > 2056 then do;
  id = count;
  count = count + 1;
  end;
drop count;
run;
PG
Qpp1941
Calcite | Level 5

it is 50001.

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 1685 views
  • 0 likes
  • 3 in conversation