<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Populating count based on missing decode value in result in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Populating-count-based-on-missing-decode-value-in-result/m-p/839395#M331907</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
    value avalf 1='Did not meet entrance criteria' 2='Lost to follow-up' 3='Voluntary Withdrawal'
        4='Study Termination' 5="Adverse Event" 6='Other';
run;
data have;
input SUBJID AVAL :8. ;
infile datalines dlm = '|';
format aval avalf.;
datalines;
1001|1
1002|2
1003|3
1004|3
1005|5
1006|6
1007|1
run;


proc report data=have completerows;
    columns aval subjid;
    define aval/group "AVAL" preloadfmt order=internal;
    define subjid/n;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 19 Oct 2022 14:51:41 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-10-19T14:51:41Z</dc:date>
    <item>
      <title>Populating count based on missing decode value in result</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Populating-count-based-on-missing-decode-value-in-result/m-p/839389#M331903</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just looking a way to do this instead of hardcoding a row into a listing. Basically I have this code list.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="smackerz1988_0-1666188967246.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/76308i1DBC200A9AAFA76E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="smackerz1988_0-1666188967246.png" alt="smackerz1988_0-1666188967246.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;That will be used for a screen status summary listing.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="smackerz1988_1-1666189123168.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/76309iB0A4DADB1C895BAC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="smackerz1988_1-1666189123168.png" alt="smackerz1988_1-1666189123168.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;So there is a value from the codelist (AVAL = 4, AVALC ="Study termination") that is not present in the data that I need to include even if the result will be zero. What is the best way of doing this?. Is it the case of putting the codelist values into an array and using a do loop to pass through AVALC for matching values?. Here is a sample of the code to illustrate the issue and what I was doing prior.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input SUBJID $ AVAL :8. AVALC :$30.;
infile datalines dlm = '|';
datalines;
1001|1|Did not meet entrance criteria
1002|2|Lost to follow-up
1003|3|Voluntary withdrawal
1004|3|Voluntary withdrawal
1005|5|Adverse event
1006|6|Other
1007|1|Did not meet entrance criteria
run;


proc sql;
   create table have1 as
   select aval as ord2, avalc as col1, count(avalc) as count, 2 as RowOrd
   from have
   group by ord2, col1
   order by ord2, col1;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2022 14:38:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Populating-count-based-on-missing-decode-value-in-result/m-p/839389#M331903</guid>
      <dc:creator>smackerz1988</dc:creator>
      <dc:date>2022-10-19T14:38:05Z</dc:date>
    </item>
    <item>
      <title>Re: Populating count based on missing decode value in result</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Populating-count-based-on-missing-decode-value-in-result/m-p/839395#M331907</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
    value avalf 1='Did not meet entrance criteria' 2='Lost to follow-up' 3='Voluntary Withdrawal'
        4='Study Termination' 5="Adverse Event" 6='Other';
run;
data have;
input SUBJID AVAL :8. ;
infile datalines dlm = '|';
format aval avalf.;
datalines;
1001|1
1002|2
1003|3
1004|3
1005|5
1006|6
1007|1
run;


proc report data=have completerows;
    columns aval subjid;
    define aval/group "AVAL" preloadfmt order=internal;
    define subjid/n;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Oct 2022 14:51:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Populating-count-based-on-missing-decode-value-in-result/m-p/839395#M331907</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-10-19T14:51:41Z</dc:date>
    </item>
    <item>
      <title>Re: Populating count based on missing decode value in result</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Populating-count-based-on-missing-decode-value-in-result/m-p/839396#M331908</link>
      <description>&lt;P&gt;Somewhere you would need to provide the information.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Proc Tabulate and Report have an option PRELOADFMT that will use all of the values of a defined format for a variable in the displayed result. An example with Proc Tabulate:&lt;/P&gt;
&lt;PRE&gt;proc format;
value aval
1='Did not meet entrance criteria'
2='Lost to follow-up'
3='Voluntary withdrawal'
4='Study termination'
5='Adverse event'
6='Other'
;

Proc tabulate data=have;
   class aval /missing preloadfmt;
   format aval aval.;
   tables aval,
          n  colpctn
          /printmiss 
   ;
run;
&lt;/PRE&gt;
&lt;P&gt;You could add Misstext='0' after the table option Printmiss to get the N to display a 0.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I use the numeric variable instead of the character as it much easier to maintain the order of appearance in the result table.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2022 14:55:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Populating-count-based-on-missing-decode-value-in-result/m-p/839396#M331908</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-10-19T14:55:16Z</dc:date>
    </item>
    <item>
      <title>Re: Populating count based on missing decode value in result</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Populating-count-based-on-missing-decode-value-in-result/m-p/839399#M331910</link>
      <description>&lt;P&gt;Thank you both I completely forgot about the preloadfmt.!&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2022 15:11:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Populating-count-based-on-missing-decode-value-in-result/m-p/839399#M331910</guid>
      <dc:creator>smackerz1988</dc:creator>
      <dc:date>2022-10-19T15:11:15Z</dc:date>
    </item>
    <item>
      <title>Re: Populating count based on missing decode value in result</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Populating-count-based-on-missing-decode-value-in-result/m-p/839400#M331911</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/430963"&gt;@smackerz1988&lt;/a&gt;&amp;nbsp;Or even slightly better:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input SUBJID $ AVAL :8. ;
infile datalines dlm = '|';
format aval avalf.;
datalines;
1001|1
1002|2
1003|3
1004|3
1005|5
1006|6
1007|1
run;
proc report data=have completerows out=a;
    column aval n pctn;
    define aval/group "AVAL" preloadfmt order=internal;
    define n/'Count';
    define pctn/f=percent9.3;
    rbreak after/summarize;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and here the SUBJID can be character or numeric&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2022 15:25:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Populating-count-based-on-missing-decode-value-in-result/m-p/839400#M331911</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-10-19T15:25:33Z</dc:date>
    </item>
  </channel>
</rss>

