BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
anming
Pyrite | Level 9
data one;
input S_id S_i score;
cards;
1 1 98
1 2 76
1 3 63
2 1 96
2 2 85
2 3 76
;
run;

data score_one;
set one;
by S_id S_i;
array ascore(3);
retain ascore1-ascore3;
/*if first.S_id then call missing(of ascore1-ascore3);*/
ascore(S_i)=score;
/*output;*/
if last.S_id then output;
keep S_id ascore1-ascore3;
run;

when I work on the reshaping through by statement, it seems the first.s_id does not take an effect when combining with the call missing routine. As shown above,
when I comments if first.S_id call missing line, the codes can generate the same data set. Call missing should assign empty values for first-id =1, but we do have
the values for the first line. I use "output" to display the loop. It is a bit confusing about the data assignment. What is the proper understanding?
1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

WIth a slight modification to your program, you can observe the effect of CALL MISSING:

data score_one before_the_last;
set one;
by S_id S_i;
array ascore(3);
retain ascore1-ascore3;
if first.S_id then call missing(of ascore1-ascore3);
ascore(S_i)=score;
output before_the_last;
if last.S_id then output score_one;
keep S_id ascore1-ascore3;
run;

View solution in original post

3 REPLIES 3
Kurt_Bremser
Super User

Since your data causes all elements of the array to be filled in every s_id group, the call missing will not have a noticeable effect. If one of your groups missed one of the values 1,2,3 for s_i, the call missing would be necessary.

Astounding
PROC Star

WIth a slight modification to your program, you can observe the effect of CALL MISSING:

data score_one before_the_last;
set one;
by S_id S_i;
array ascore(3);
retain ascore1-ascore3;
if first.S_id then call missing(of ascore1-ascore3);
ascore(S_i)=score;
output before_the_last;
if last.S_id then output score_one;
keep S_id ascore1-ascore3;
run;
anming
Pyrite | Level 9
this is really cool!

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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
  • 3 replies
  • 923 views
  • 3 likes
  • 3 in conversation