BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
shasank
Quartz | Level 8

Hi Community,

 

I need your help with the below problem.

 

If the per ID rows count is <6 then I would like to add the additional missing rows with the Score = 0;

 

data Dsn;
input ID score;
cards;
1 48
1 45
1 50
1 42
1 41
2 51
2 52
2 43
2 52
;
run;

 

Expected Output:

 

IDScore
148
145
150
142
141
10
251
252
243
252
20
20

 

Any help is appreciated. 

 

Thank you for your time. 

 

Best,

SC. 

 

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20
data Dsn;
input ID score;
cards;
1 48
1 45
1 50
1 42
1 41
2 51
2 52
2 43
2 52
;
run;

data want;
 do _n_=1 by 1 until(last.id);
  set dsn;
  by id;
  output;
 end;
 do _n_=_n_+1 to 6;
 score=0;
 output;
 end;
run;

View solution in original post

1 REPLY 1
novinosrin
Tourmaline | Level 20
data Dsn;
input ID score;
cards;
1 48
1 45
1 50
1 42
1 41
2 51
2 52
2 43
2 52
;
run;

data want;
 do _n_=1 by 1 until(last.id);
  set dsn;
  by id;
  output;
 end;
 do _n_=_n_+1 to 6;
 score=0;
 output;
 end;
run;