dear all
I have to repeat each value of a variable for ten times.
i have do it for 357 values
my data set format is as follows
companycode |
comp1 |
comp2 |
comp3 |
…………. |
……… |
………… |
comp357 |
required format is
companycode |
comp1 |
comp1 |
comp1 |
comp1 |
comp1 |
comp1 |
comp1 |
comp1 |
comp1 |
comp1 |
comp2 |
comp2 |
comp2 |
comp2 |
comp2 |
comp2 |
comp2 |
comp2 |
comp2 |
comp2 |
please suggest me a SAS code for doing it
thanks in advance
Do like this 🙂
data have;
input companycode $;
datalines;
comp1
comp2
comp3
;
data want;
set have;
do _N_=1 to 10;
output;
end;
run;
I assume that you've used the automatic variable _N_ is a typo.
@srikanthyadav44 Don't use _N_ but "anything else" as name for the counter variable.
data want(drop=_i);
set have;
do _i=1 to 10;
output;
end;
run;
@Patrick, your assumption is incorrect. I like to use _N_ when a temporary counter variable is needed in a simple setting. If you have thoughts on the matter, I am all ears though 🙂
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.