Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You haven't provided the full context for this project, so it's unclear if this will work for you - but I think this is what I'd do.</p> <p>First off, you're in SAS, use SAS where it's best - counting things. Instead of the PROC SQL and the data step, use PROC MEANS:</p> <pre><code>proc means data=estimation n; var &amp;parameters.; run; </code></pre> <p>That, without any extra work, gets you the number of nonmissing values for all of your variables in one nice table.</p> <p>Secondly, if there is a reason to do the PROC SQL, it's probably a bit more logical to structure it this way.</p> <pre><code>proc sql; select %do i = 1 %to %sysfunc(countw(&amp;parameters.)); count(%scan(&amp;parameters.,&amp;i.) ) as Parameter_&amp;i., /* or could reuse the %scan result to name this better*/ %end; count(1) as Total_Obs from estimation; quit; </code></pre> <p>The final Total Obs column is useful to simplify the code (dealing with the extra comma is mildly annoying). You could also put it at the start and prepend the commas.</p> <p>You finally could also drive this from a dataset rather than a macro variable. I like that better, in general, as it's easier to deal with in a lot of ways. If your parameter list is in a data set somewhere (one parameter per row, in the dataset "Parameters", with "var" as the name of the column containing the parameter), you could do</p> <pre><code>proc sql; select cats('%countme(var=',var,')') into :countlist separated by ',' from parameters; quit; %macro countme(var=); count(&amp;var.) as &amp;var._count %mend countme; proc sql; select &amp;countlist from estimation; quit; </code></pre> <p>This I like the best, as it is the simplest code and is very easy to modify. You could even drive it from a contents of estimation, if it's easy to determine what your potential parameters might be from that (or from <code>dictionary.columns</code>).</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload