<?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: Amount of a field which is filled or empty in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Amount-of-a-field-which-is-filled-or-empty/m-p/721623#M223692</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/329668"&gt;@Caro17&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;This one works. Thank you very much.&lt;BR /&gt;&lt;BR /&gt;How can I do it if the variable is a date or a checkbox (yes/no)? What have to be changed?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If the concern is missing or not, then nothing would need to be changed. SAS datasets only have two data types: numeric and character. Data imported to SAS will become one of those types. &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your mean something else, provide actual example data and what you expect as a result for that example.&lt;/P&gt;</description>
    <pubDate>Wed, 24 Feb 2021 16:56:38 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2021-02-24T16:56:38Z</dc:date>
    <item>
      <title>Amount of a field which is filled or empty</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Amount-of-a-field-which-is-filled-or-empty/m-p/721483#M223634</link>
      <description>&lt;P&gt;Hey,&lt;/P&gt;&lt;P&gt;I just want to have a simple thing, but I can't find a solution.&lt;/P&gt;&lt;P&gt;I want to count a field how often it is filled or empty.&lt;/P&gt;&lt;P&gt;How can I do this?&lt;/P&gt;&lt;P&gt;Thanx a lot for you help.&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;Caro&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2021 06:26:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Amount-of-a-field-which-is-filled-or-empty/m-p/721483#M223634</guid>
      <dc:creator>Caro17</dc:creator>
      <dc:date>2021-02-24T06:26:32Z</dc:date>
    </item>
    <item>
      <title>Re: Amount of a field which is filled or empty</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Amount-of-a-field-which-is-filled-or-empty/m-p/721484#M223635</link>
      <description>&lt;P&gt;Is the data numeric or character?&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2021 06:29:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Amount-of-a-field-which-is-filled-or-empty/m-p/721484#M223635</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2021-02-24T06:29:34Z</dc:date>
    </item>
    <item>
      <title>Re: Amount of a field which is filled or empty</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Amount-of-a-field-which-is-filled-or-empty/m-p/721486#M223637</link>
      <description>Can be both. It depends on the field. Therefore I want to have a solution for both cases, please. Thank you!</description>
      <pubDate>Wed, 24 Feb 2021 06:32:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Amount-of-a-field-which-is-filled-or-empty/m-p/721486#M223637</guid>
      <dc:creator>Caro17</dc:creator>
      <dc:date>2021-02-24T06:32:07Z</dc:date>
    </item>
    <item>
      <title>Re: Amount of a field which is filled or empty</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Amount-of-a-field-which-is-filled-or-empty/m-p/721489#M223640</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/329668"&gt;@Caro17&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Have you tried something like the below. If you need something different then please provide some examples of input data and what you want to see output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* create data with missing values */
data have;
   infile datalines truncover dsd;

   input
      char_var : $10.
      num_var  :   8.
   ;

   datalines;
abc,123
def,
,456
,
,789
;


/* initialise counts */
%let char_var_missing_count = 0;
%let num_var_missing_count  = 0;


/* count missing values */
proc sql noprint;
   select
       sum(missing(char_var))
      ,sum(missing(num_var))
   into
       :char_var_missing_count
      ,:num_var_missing_count
   from
      have
   ;
quit;


/* display values in log */
%put &amp;amp;=char_var_missing_count;
%put &amp;amp;=num_var_missing_count;
&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;Kind regards,&lt;/P&gt;
&lt;P&gt;Amir.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2021 07:52:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Amount-of-a-field-which-is-filled-or-empty/m-p/721489#M223640</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2021-02-24T07:52:09Z</dc:date>
    </item>
    <item>
      <title>Re: Amount of a field which is filled or empty</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Amount-of-a-field-which-is-filled-or-empty/m-p/721490#M223641</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/329668"&gt;@Caro17&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hey,&lt;/P&gt;
&lt;P&gt;I just want to have a simple thing, but I can't find a solution.&lt;/P&gt;
&lt;P&gt;I want to count a field how often it is filled or empty.&lt;/P&gt;
&lt;P&gt;How can I do this?&lt;/P&gt;
&lt;P&gt;Thanx a lot for you help.&lt;/P&gt;
&lt;P&gt;Best regards&lt;/P&gt;
&lt;P&gt;Caro&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;One way:&lt;/P&gt;
&lt;PRE&gt;data have;
   input x y $;
datalines;
1 a
2 .
. b
4 c
. .
5 f
6 .
;

proc format;
value nummiss
.= 'Missing'
other = 'Not missing'
;
value $charmiss
' '='Missing'
other= 'Not missing'
;
run;

proc freq data=have;
  tables _all_/missing;
  format _numeric_ nummiss. _character_ $charmiss.;
run;&lt;/PRE&gt;
&lt;P&gt;The custom formats are designed so that filled (not missing) and not filled (missing) are reported.&lt;/P&gt;
&lt;P&gt;Proc freq uses a small example data that was build to include a few missing values to demonstrate. The _all_ on the tables statement says to analyze all variables. The option MISSING on the tables statement says to include the missing values in the counting.&lt;/P&gt;
&lt;P&gt;The format using special variable list names _numeric_ and _character_ , meaning all numeric and all character variables and assigns the custom format.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2021 08:07:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Amount-of-a-field-which-is-filled-or-empty/m-p/721490#M223641</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-02-24T08:07:48Z</dc:date>
    </item>
    <item>
      <title>Re: Amount of a field which is filled or empty</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Amount-of-a-field-which-is-filled-or-empty/m-p/721572#M223678</link>
      <description>This one works. Thank you very much.&lt;BR /&gt;&lt;BR /&gt;How can I do it if the variable is a date or a checkbox (yes/no)? What have to be changed?</description>
      <pubDate>Wed, 24 Feb 2021 14:06:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Amount-of-a-field-which-is-filled-or-empty/m-p/721572#M223678</guid>
      <dc:creator>Caro17</dc:creator>
      <dc:date>2021-02-24T14:06:29Z</dc:date>
    </item>
    <item>
      <title>Re: Amount of a field which is filled or empty</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Amount-of-a-field-which-is-filled-or-empty/m-p/721573#M223679</link>
      <description>Is it possible to do it for more variables in one table?</description>
      <pubDate>Wed, 24 Feb 2021 14:09:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Amount-of-a-field-which-is-filled-or-empty/m-p/721573#M223679</guid>
      <dc:creator>Caro17</dc:creator>
      <dc:date>2021-02-24T14:09:26Z</dc:date>
    </item>
    <item>
      <title>Re: Amount of a field which is filled or empty</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Amount-of-a-field-which-is-filled-or-empty/m-p/721622#M223691</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/329668"&gt;@Caro17&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Is it possible to do it for more variables in one table?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You would have to provide some example data and what you expect.&lt;/P&gt;
&lt;P&gt;It may be that what you want here would come by creating an output data set from proc freq. That could be done by adding&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ods onewayfreqs= freqdatasetname;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then print that data set, or manipulate as needed.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2021 16:54:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Amount-of-a-field-which-is-filled-or-empty/m-p/721622#M223691</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-02-24T16:54:06Z</dc:date>
    </item>
    <item>
      <title>Re: Amount of a field which is filled or empty</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Amount-of-a-field-which-is-filled-or-empty/m-p/721623#M223692</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/329668"&gt;@Caro17&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;This one works. Thank you very much.&lt;BR /&gt;&lt;BR /&gt;How can I do it if the variable is a date or a checkbox (yes/no)? What have to be changed?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If the concern is missing or not, then nothing would need to be changed. SAS datasets only have two data types: numeric and character. Data imported to SAS will become one of those types. &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your mean something else, provide actual example data and what you expect as a result for that example.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2021 16:56:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Amount-of-a-field-which-is-filled-or-empty/m-p/721623#M223692</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-02-24T16:56:38Z</dc:date>
    </item>
  </channel>
</rss>

