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;

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

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!

Register now

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 671 views
  • 0 likes
  • 2 in conversation