BookmarkSubscribeRSS Feed


I have made frequent use of the CALL MISSING function, most commonly with numeric arrays, as in

array myvars {*}   a1-a5 m1-m5;
call missing(of myvars{*});

But instead of re-setting to missing, I often (probably most of the time) would prefer to set all the variables to a zero (or to some other constant value), as in

 

array myvars {*}  a1-a5  m1-m5;
call constant(0,of myvars{*});
call constant(0,of _numeric_);

And if the introduction of a user-specified constant is problematic, then just a CALL ZERO function would serve pretty well.

 

And less frequently needed, but useful if for no other reason than to parallel other function pairs, such as COALESCE/COALESCEC, it would be nice to have a call constant pair as well,  i.e. CALL CONSTANT/CALL CONSTANTC, such that this is available.

 

array myvars {*}  $ char1-char5;
call constantc('****',of myvars{*});
call constantc('****',of _character_);

 

 

5 Comments
PeterClemmensen
Tourmaline | Level 20

I like this. Would be very useful.

 

For the numeric part, PROC FCMP does provide something like this with Call Fillmatrix and Call Zeromatrix. However, you would have to compile them with FCMP first to use them in a data step. Also, you would not be able to use it with the _numeric_ keyword. 

ChrisNZ
Tourmaline | Level 20
mkeintz
PROC Star

@ChrisNZ 

 

Yes, I was aware of it (in fact, I think I voted for it).  But it's 4 years old now, so I thought it might be worth a new time stamp (and with a minor tweak to also request a character-variable analog).  And Also, I'll be promoting it with my sas communities signature for a while - see if it gets any traction.

 

But I should mention this proposal is a reprise of yours.  I'll make an edit in this ballot idea.

 

Editted note:  Apparently I can't edit a ballot idea (just my comments), so the reference can't be put there.

 

 

ChrisNZ
Tourmaline | Level 20

@mkeintz No worries, and any method is good if it can get SAS to implement suggestions.

I am not holding my breath. The conversion ratio must be minute. 🙂

 

RichardDeVen
Barite | Level 11

What might be even more useful would be

CALL INITIALIZE (ARRAY, array initialization syntax)

or

CALL INITIALIZEX (ARRAY, 'array initialization syntax string')