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;
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.