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
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;
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;
Thanks a lot. It worked
Do you always have to specify the values in "Window"? Can this be modified for the case with lots of names?
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 .
OK thanks, In the datalines argument Moh and Raj have been specified. Can these be done 'on the fly'?
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.
Ready to level-up your skills? Choose your own adventure.