As the first step in the decommissioning of sasCommunity.org the site has been converted to read-only mode.


Here are some tips for How to share your SAS knowledge with your professional network.


Difference between revisions of "Tips:Use CALL MISSING to Set a List of Variables to Missing"

From sasCommunity
Jump to: navigation, search
m (fixed category)
(formatting, as per Code Like It Matters / indentation)
 
Line 1: Line 1:
<div style="float:right"><source lang='sas'>data annual(keep=year q: totsales);
+
<div style="float:right"><source lang='sas'>
set sashelp.retail(keep=sales date year);
+
data annual(keep=year q: totsales);
by year;
+
    set sashelp.retail(keep=sales date year);
retain q1-q4 .;
+
    by year;
array annual {4} q1-q4;
+
 
if first.year then call missing(of annual{*});
+
    retain q1-q4 .;
annual{qtr(date)}=sales;
+
    array annual {4} q1-q4;
if last.year then do;
+
 
  totsales=sum(of q:);
+
    if first.year then call missing(of annual{*});
  output annual;
+
 
end;
+
    annual{qtr(date)}=sales;
 +
 
 +
    if last.year then do;
 +
      totsales=sum(of q:);
 +
      output annual;
 +
    end;
 
run;
 
run;
 
</source></div>
 
</source></div>

Latest revision as of 14:47, 10 November 2017

data annual(keep=year q: totsales);
    set sashelp.retail(keep=sales date year);
    by year;
 
    retain q1-q4 .;
    array annual {4} q1-q4;
 
    if first.year then call missing(of annual{*});
 
    annual{qtr(date)}=sales;
 
    if last.year then do;
       totsales=sum(of q:);
       output annual;
    end;
run;

The CALL MISSING routine can be used to set all of its arguments to missing. The arguments can be numeric, character, or even array references.


....see also

....read more

Submitted By Art Carpenter