i want to create new column whereever missing is after that it should start give number like sequence123.123.123.
below is my data ihave tried but i not getting the exact one.please help me,
data new;
input have ;
datalines;
2
1
9
.
1
2
.
5
1
2
.
9
7
5
;
PROC SQL;
CREATE TABLE WORK.QUERY_FOR_NEW AS
SELECT t1.have,
/* getting*/
(case when t1.have = . then . else monotonic() end) AS getting
FROM WORK.NEW t1;
QUIT;
have | getting | Want |
. | . | |
2 | 1 | 1 |
1 | 2 | 2 |
9 | 3 | 3 |
. | . | |
1 | 4 | 1 |
2 | 5 | 2 |
. | . | |
5 | 6 | 1 |
1 | 7 | 2 |
2 | 8 | 3 |
. | . | |
9 | 9 | 1 |
7 | 10 | 2 |
5 | 11 | 3 |
Try adding this code to your first data step.
retain want 0;
if have=. then want=.;
else; want+1;
Jim
Try adding this code to your first data step.
retain want 0;
if have=. then want=.;
else; want+1;
Jim
i tried above code
Data New1;
set new;
retain want 0;
if have=. then want=.;
want+1;
run;
i got wherever missing(.) its retained as 1 so tried instead of missing(.) as (-1) its working fine.
Data New1;
set new;
retain want 0;
if have=. then want= -1;
want+1;
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.