BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
DDawaba
Calcite | Level 5

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."

 

NAMEBR_CODEBKTDomain
A194223
A194314
A19448

 

Repeated 23 times...

 BR_CODEBKTDomain
A194223
A194223
A194223
A194223
A194223
A194223
A194223
A194223
A194223
A194223
A194223
A1942….
A1942….
A1942….
A1942….
1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

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;

View solution in original post

2 REPLIES 2
PeterClemmensen
Tourmaline | Level 20

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;
DDawaba
Calcite | Level 5
Yes! Thanks.
The variable contained (.)

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

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!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 919 views
  • 2 likes
  • 2 in conversation