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 🙂
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 lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.