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

Hi all,

 

I have a dataset that has a variable "start" and a variable "end" with count data representing an interval. I want to convert that data to be 1 row per count rather than by interval, like this:

 

Subject  start  end  var

1             1       3       x

1             4       5       y

2             1       5       z

 

To look like this:

 

Subject  count  var

1             1        x

1             2        x

1             3        x

1             4        y

1             5        y

2             1        z

2             2        z

...

 

I dont know how to manipulate the array code to reference these variables instead of doing from i=1 to x. Any help is appreciated. Thank you..

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Qinzhu
SAS Employee

Is below code what you want? 

data foo;
	input subject start end var $;
datalines;
1 1 3 x
1 4 5 y
2 1 5 z
;

data convert;
	set foo;
	do count=start to end;
		output;
	end;
	drop start end;
run;

 

View solution in original post

1 REPLY 1
Qinzhu
SAS Employee

Is below code what you want? 

data foo;
	input subject start end var $;
datalines;
1 1 3 x
1 4 5 y
2 1 5 z
;

data convert;
	set foo;
	do count=start to end;
		output;
	end;
	drop start end;
run;

 

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 1 reply
  • 143 views
  • 0 likes
  • 2 in conversation