<?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: Show categories with no data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Show-categories-with-no-data/m-p/773386#M245686</link>
    <description>&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;I have corrected the&amp;nbsp; values in&amp;nbsp; have data set,&lt;/P&gt;
&lt;P&gt;Still get null values in want data set, why?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
Data have;
input VAR $12.   VarIssue $ 14-16   category  $ 18-28  nr pct;
cards;
cat_ageYears Age (a) Null    100 10
cat_ageYears Age (c) 26-31   300 30
cat_ageYears Age (d) 32-42   200 20
cat_ageYears Age (e) 43-67   100 10
cat_ageYears Age (f) more 67 300 30
;
Run;
proc format;
value $AgeFmt (multilabel notsorted)
Other ='(a) Null'
'26-31'='(c) 26-31'
'32-42'='(d) 32-42'
'43-67'='(e) 43-67'
'more 67'='(f) more 67'
/**The categories that need to add to summary table**/
'less 25'='(b) less 25'
'All Other'='(g) All Other'
;
Run;
proc summary data =have nway completetypes;
class VAR;
Class VarIssue;
class Category / preloadfmt mlf order=formatted;
var nr pct;
output out = want(drop = _:) sum(nr)=nr sum(pct)=pct ;
format Category $AgeFmt.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 11 Oct 2021 12:24:52 GMT</pubDate>
    <dc:creator>Ronein</dc:creator>
    <dc:date>2021-10-11T12:24:52Z</dc:date>
    <item>
      <title>Show categories with no data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Show-categories-with-no-data/m-p/773365#M245673</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I am trying to show in summary report also categories that don't appear in raw data set.&lt;/P&gt;
&lt;P&gt;What is the problem in my code that I get null values???&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
Data have;
input VAR $12.   VarIssue $ 14-17   category  $ 19-28  nr pct;
cards;
cat_ageYears Age (a) Null    100 10
cat_ageYears Age (c) 26-31   300 30
cat_ageYears Age (d) 32-42   200 20
cat_ageYears Age (e) 43-67   100 10
cat_ageYears Age (f) more 67 300 30
;
Run;

proc format;
value $AgeFmt (multilabel notsorted)
Other ='(a) Null'
'less 25'='(b) less 25'
'26-31'='(c) 26-31'
'32-42'='(d) 32-42'
'43-67'='(e) 43-67'
'more 67'='(f) more 67'
'All Other'='(g) All Other'
;
Run;


proc summary data =have nway completetypes;
class VAR;
Class VarIssue;
class Category / preloadfmt mlf order=formatted;
var nr pct;
output out = want(drop = _:) sum(nr)=nr sum(pct)=pct ;
format Category $AgeFmt.;
run;
/****problem- Rows get null value!!!!****/&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 11 Oct 2021 11:30:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Show-categories-with-no-data/m-p/773365#M245673</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2021-10-11T11:30:11Z</dc:date>
    </item>
    <item>
      <title>Re: Show categories with no data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Show-categories-with-no-data/m-p/773371#M245677</link>
      <description>&lt;P&gt;I don't see any "null values" when I run your code. Show us.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, your format $agefmt. is applied to variable category, and none of the values in category actually are assigned a format, can you see why?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Lastly, why not leave value of AGE as a number instead of a text string, and then assign formats to those numbers? This make a lot more sense than the text strings for category that you are using.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Oct 2021 11:47:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Show-categories-with-no-data/m-p/773371#M245677</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-10-11T11:47:09Z</dc:date>
    </item>
    <item>
      <title>Re: Show categories with no data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Show-categories-with-no-data/m-p/773374#M245679</link>
      <description>&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;This is the result of "want" data set&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As you can see except of first row all other rows get null values on fields nr and pct.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ronein_0-1633952979199.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/64568i8B265133B558898A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ronein_0-1633952979199.png" alt="Ronein_0-1633952979199.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Oct 2021 11:50:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Show-categories-with-no-data/m-p/773374#M245679</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2021-10-11T11:50:19Z</dc:date>
    </item>
    <item>
      <title>Re: Show categories with no data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Show-categories-with-no-data/m-p/773375#M245680</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
Data have;
input VAR $12.   VarIssue $ 14-17   category  $ 19-28  nr pct;
cards;
cat_ageYears Age (a) Null    100 10
cat_ageYears Age (c) 26-31   300 30
cat_ageYears Age (d) 32-42   200 20
cat_ageYears Age (e) 43-67   100 10
cat_ageYears Age (f) more 67 300 30
;
Run;
proc format;
value $AgeFmt (multilabel notsorted)
Other ='(a) Null'
'26-31'='(c) 26-31'
'32-42'='(d) 32-42'
'43-67'='(e) 43-67'
'more 67'='(f) more 67'
/**The categories that need to add to summary table**/
'less 25'='(b) less 25'
'All Other'='(g) All Other'
;
Run;

proc summary data =have nway completetypes;
class VAR;
Class VarIssue;
class Category / preloadfmt mlf order=formatted;
var nr pct;
output out = want(drop = _:) sum(nr)=nr sum(pct)=pct ;
format Category $AgeFmt.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 11 Oct 2021 11:53:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Show-categories-with-no-data/m-p/773375#M245680</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2021-10-11T11:53:05Z</dc:date>
    </item>
    <item>
      <title>Re: Show categories with no data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Show-categories-with-no-data/m-p/773376#M245681</link>
      <description>&lt;P&gt;Hello, This is the summary table that was created by others and the task is to add missing categories.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Oct 2021 11:54:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Show-categories-with-no-data/m-p/773376#M245681</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2021-10-11T11:54:40Z</dc:date>
    </item>
    <item>
      <title>Re: Show categories with no data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Show-categories-with-no-data/m-p/773379#M245683</link>
      <description>&lt;P&gt;My apologies, when I ran the code myself, the missing values were there, and I didn't look at the correct data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your formats do not apply to the data. I am asking you to look carefully at the formats and see this yourself. One of your format values is the text string '26-31', but this text string '26-31' does not appear in your original data set. Your formats won't work. You need to have formats that actually appear in the data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Oct 2021 12:04:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Show-categories-with-no-data/m-p/773379#M245683</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-10-11T12:04:37Z</dc:date>
    </item>
    <item>
      <title>Re: Show categories with no data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Show-categories-with-no-data/m-p/773386#M245686</link>
      <description>&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;I have corrected the&amp;nbsp; values in&amp;nbsp; have data set,&lt;/P&gt;
&lt;P&gt;Still get null values in want data set, why?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
Data have;
input VAR $12.   VarIssue $ 14-16   category  $ 18-28  nr pct;
cards;
cat_ageYears Age (a) Null    100 10
cat_ageYears Age (c) 26-31   300 30
cat_ageYears Age (d) 32-42   200 20
cat_ageYears Age (e) 43-67   100 10
cat_ageYears Age (f) more 67 300 30
;
Run;
proc format;
value $AgeFmt (multilabel notsorted)
Other ='(a) Null'
'26-31'='(c) 26-31'
'32-42'='(d) 32-42'
'43-67'='(e) 43-67'
'more 67'='(f) more 67'
/**The categories that need to add to summary table**/
'less 25'='(b) less 25'
'All Other'='(g) All Other'
;
Run;
proc summary data =have nway completetypes;
class VAR;
Class VarIssue;
class Category / preloadfmt mlf order=formatted;
var nr pct;
output out = want(drop = _:) sum(nr)=nr sum(pct)=pct ;
format Category $AgeFmt.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 11 Oct 2021 12:24:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Show-categories-with-no-data/m-p/773386#M245686</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2021-10-11T12:24:52Z</dc:date>
    </item>
    <item>
      <title>Re: Show categories with no data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Show-categories-with-no-data/m-p/773388#M245687</link>
      <description>&lt;P&gt;Let's take a simple example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
value $sexf 'M'='Male';
run;
proc print data=sashelp.class;
format sex $sexf.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What does this do? It finds every case where the variable SEX has value 'M' and it makes the 'M' appear as the text string 'Male'.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In your case, your format is trying to find the text string '26-31' and make it appear as '(c) 26-31'. However, the text string '26-31' does not appear in your data set. Please look at your data set and see that the value of variable CATEGORY is never '26-31'. (If you do see it, then show me)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your formats are wrong. They do not work. You need to fix them.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Oct 2021 12:30:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Show-categories-with-no-data/m-p/773388#M245687</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-10-11T12:30:31Z</dc:date>
    </item>
    <item>
      <title>Re: Show categories with no data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Show-categories-with-no-data/m-p/773473#M245722</link>
      <description>Thank you again, I will fix it and will run the code tomorrow's morning and will verify that at it will work, cheers</description>
      <pubDate>Mon, 11 Oct 2021 20:29:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Show-categories-with-no-data/m-p/773473#M245722</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2021-10-11T20:29:49Z</dc:date>
    </item>
    <item>
      <title>Re: Show categories with no data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Show-categories-with-no-data/m-p/773544#M245755</link>
      <description>&lt;P&gt;Hello, I have fixed the proc format but still get an error&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;ERROR: A format range for the variable category could not be pre-loaded.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.WANT may be incomplete.  When this step was stopped there were 0 observations and 5 variables.
WARNING: Data set WORK.WANT was not replaced because this step was stopped.
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
Data have;
input VAR $12.   VarIssue $ 14-17   category  $ 19-28  nr pct;
cards;
cat_ageYears Age (a) Null    100 10
cat_ageYears Age (c) 26-31   300 30
cat_ageYears Age (d) 32-42   200 20
cat_ageYears Age (e) 43-67   100 10
cat_ageYears Age (f) more 67 300 30
;
Run;
proc format;
value $AgeFmt (multilabel notsorted)
'(a) Null'='(a) Null'
'(b) less 25'='(b) less 25'
'(c) 26-31'='(c) 26-31'
'(d) 32-42'='(d) 32-42'
'(e) 43-67'='(e) 43-67'
'(f) more 67'='(f) more 67'
'(g) All Other'='(g) All Other'
;
Run;
proc summary data =have nway completetypes;
class VAR;
Class VarIssue;
class Category / preloadfmt mlf order=data;
var nr pct;
output out = want(drop = _:) sum(nr)=nr sum(pct)=pct ;
format Category $AgeFmt.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 06:23:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Show-categories-with-no-data/m-p/773544#M245755</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2021-10-12T06:23:29Z</dc:date>
    </item>
  </channel>
</rss>

