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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 2016 views
  • 0 likes
  • 3 in conversation