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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 748 views
  • 1 like
  • 4 in conversation