BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
hello28
Calcite | Level 5

 

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.

 

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

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;



View solution in original post

1 REPLY 1
novinosrin
Tourmaline | Level 20

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;



Ready to join fellow brilliant minds for the SAS Hackathon?

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!
How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 434 views
  • 1 like
  • 2 in conversation