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

 

 

Hi. I'm trying to figure out the importance/purpose of the Call Missing function being used 
in the code below. The code itself reshapes the data so that all unique From_Dt values
appear in a comma delimited list.

Any help would be greatly appreciated.

data
have; input BENE FROM_DT :date9.; format from_dt date9.; cards;12345 23OCT2010 12345 11NOV2015 12345 11NOV2015 12345 15DEC2011 12345 11NOV2015; data want; array t(999) $9 _temporary_; call missing(of t(*),n); do until(last.bene); set have; by bene; temp=put(from_dt,date9.); if temp not in t then do; n+1; t(n)=temp; end; end; want_list=catx(', ',of t(*)); keep bene want_list; run;

 

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

All the variables mentioned in CALL MISSING are retained.

 

  • Elements of a _temporary_ array are automatically retained.
  • N is automatically retained because of the statement:  n+1;

Without CALL MISSING, observations for the second BENE would add to the values found for the previous BENE.  CALL MISSING allows each BENE to start with a clean slate and to come up with the dates that belong to that BENE only.

View solution in original post

4 REPLIES 4
Astounding
PROC Star

All the variables mentioned in CALL MISSING are retained.

 

  • Elements of a _temporary_ array are automatically retained.
  • N is automatically retained because of the statement:  n+1;

Without CALL MISSING, observations for the second BENE would add to the values found for the previous BENE.  CALL MISSING allows each BENE to start with a clean slate and to come up with the dates that belong to that BENE only.

buechler66
Barite | Level 11
Thanks so much. That makes complete sense now. Thanks for taking the time to help. Much appreciated.
novinosrin
Tourmaline | Level 20

Temporary arrays values are retained across iterations of the datastep i.e when sas processes a new record, values are not reset to missing which is the default. Therefore to override the behavior of temp array, call missing assigns missing values for all array elements. HTH

PGStats
Opal | Level 21

The data step concatenates all the distinct dates from each BENE group. The call missing erases the dates from the previous BENE group and resets the value of n to missing. Without that call, you could get some dates from the previous BENE group showing up in the current one.

PG

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 4 replies
  • 943 views
  • 1 like
  • 4 in conversation