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.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.