For the below table, I need the first combination of "A, 194 and 2" to be duplicated or repeated 23 times and the second combination to be duplicated or repeated 14 times.
This code worked on another example but failed on this one. Any help?
do _N_= 1 to Domain;
output; end;
Error: "Invalid DO loop control information, either the INITIAL or TO expression is missing or the BY expression is missing, zero,
or invalid."
NAME | BR_CODE | BKT | Domain |
A | 194 | 2 | 23 |
A | 194 | 3 | 14 |
A | 194 | 4 | 8 |
Repeated 23 times...
BR_CODE | BKT | Domain | |
A | 194 | 2 | 23 |
A | 194 | 2 | 23 |
A | 194 | 2 | 23 |
A | 194 | 2 | 23 |
A | 194 | 2 | 23 |
A | 194 | 2 | 23 |
A | 194 | 2 | 23 |
A | 194 | 2 | 23 |
A | 194 | 2 | 23 |
A | 194 | 2 | 23 |
A | 194 | 2 | 23 |
A | 194 | 2 | …. |
A | 194 | 2 | …. |
A | 194 | 2 | …. |
A | 194 | 2 | …. |
I suspect this happens because Domain = . in one of the obs. Try this
data have;
input NAME $ BR_CODE BKT Domain;
datalines;
A 194 2 23
A 194 3 14
A 194 4 8
A 194 4 .
;
data want;
set have;
do _N_ = 1 to max(Domain, 0);
output;
end;
run;
I suspect this happens because Domain = . in one of the obs. Try this
data have;
input NAME $ BR_CODE BKT Domain;
datalines;
A 194 2 23
A 194 3 14
A 194 4 8
A 194 4 .
;
data want;
set have;
do _N_ = 1 to max(Domain, 0);
output;
end;
run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.