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 🙂
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.