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;
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: