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)
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...
50001 or 5001?
data want;
retain count 5001;
set have;
if id > 2056 then do;
id = count;
count = count + 1;
end;
drop count;
run;
50001 or 5001?
data want;
retain count 5001;
set have;
if id > 2056 then do;
id = count;
count = count + 1;
end;
drop count;
run;
it is 50001.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.