Hi,
i have a sequence of observations as follows
0
1
2
3
4
24
25
26
I need to convert the continuous sequence into variables as below
var1 var2 var3 var4
0 4 24 26
i.e whenever there is a break in sequence, i need to capture min and max of previous sequence and store it in variable.
do you want a production code or fun solution. if former,
how many records do you estimate to have?
what would be array size aka horizontal
data have;
input n;
cards;
0
1
2
3
4
24
25
26
;
/*fun solution*/
data t;
set have;
if dif(n) ne 1 then k+1;
run;
data t1;
set t;
by k;
if first.k or last.k;
run;
proc transpose data=t1 out=want;
var n;
run;
do you want a production code or fun solution. if former,
how many records do you estimate to have?
what would be array size aka horizontal
data have;
input n;
cards;
0
1
2
3
4
24
25
26
;
/*fun solution*/
data t;
set have;
if dif(n) ne 1 then k+1;
run;
data t1;
set t;
by k;
if first.k or last.k;
run;
proc transpose data=t1 out=want;
var n;
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.