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

Hi

 

Please help me with below problem. I need to multiply rows based on the value in the field. For example my data like this below:

 

Name Window

Moh    3

Raj     4

 

I would like my output to be mulitplied w..r.t window

 

Name Window

Moh   3

Moh   3

Moh   3

Raj     4

Raj     4

Raj    4

Raj   4

 

I am not able to think how can I approach this problem. Any hints are welcome

1 ACCEPTED SOLUTION

Accepted Solutions
pearsoninst
Pyrite | Level 9
data newdata; 
Window = Window; 
input Name$ Window; 
do i = 1 to Window; 
output; 
end; 
datalines; 
Moh 3 
Raj 4 
; run; Proc Print data = newdata; run;

View solution in original post

6 REPLIES 6
pearsoninst
Pyrite | Level 9
data newdata; 
Window = Window; 
input Name$ Window; 
do i = 1 to Window; 
output; 
end; 
datalines; 
Moh 3 
Raj 4 
; run; Proc Print data = newdata; run;
bnarang
Calcite | Level 5

Thanks a lot. It worked

pearsoninst
Pyrite | Level 9
welcome
David2
Calcite | Level 5

Do you always have to specify the values in "Window"? Can this be modified for the case with lots of names?

pearsoninst
Pyrite | Level 9
Window = Window; it will calculate the number you have specified in the the variable window.
So Moh has 3 window so when do loop start i will take 3 (i = 1 to 3 )with the first obs which is raj and then
i will take 4 (i = 1 to 4 ) and the window value in Raj has 4 . And it will work with lots of names .

David2
Calcite | Level 5

OK thanks,  In the datalines argument Moh and Raj have been specified. Can these be done 'on the fly'?

CFC_SAS_Communities_400x225.jpg

Call for content now open!

It's your turn to help shape SAS Innovate 2027. Share your expertise and inspire the SAS community.

Submit your proposal →

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 4607 views
  • 1 like
  • 3 in conversation