## Multiply rows base on values in field

Solved
Frequent Contributor
Posts: 86

# Multiply rows base on values in field

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

Accepted Solutions
Solution
‎11-03-2015 03:36 AM
Frequent Contributor
Posts: 108

## Re: Multiply rows base on values in field

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

All Replies
Solution
‎11-03-2015 03:36 AM
Frequent Contributor
Posts: 108

## Re: Multiply rows base on values in field

```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;```
Frequent Contributor
Posts: 86

## Re: Multiply rows base on values in field

Thanks a lot. It worked

Frequent Contributor
Posts: 108

welcome
New Contributor
Posts: 2

## Re: Multiply rows base on values in field

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

Frequent Contributor
Posts: 108

## Re: Multiply rows base on values in field

`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 . `
New Contributor
Posts: 2

## Re: Multiply rows base on values in field

[ Edited ]

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

🔒 This topic is solved and locked.

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