<?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: macro to check percentage of missing values in a dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/macro-to-check-percentage-of-missing-values-in-a-dataset/m-p/676020#M203774</link>
    <description>wanted percenatges of XX , YY by Category &lt;BR /&gt;&lt;BR /&gt;XX	YY	Category&lt;BR /&gt;100	.	A&lt;BR /&gt;200	20	A&lt;BR /&gt;300	30	B&lt;BR /&gt;400	.	C&lt;BR /&gt;500	.	C&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Tue, 11 Aug 2020 22:18:07 GMT</pubDate>
    <dc:creator>chennupriya</dc:creator>
    <dc:date>2020-08-11T22:18:07Z</dc:date>
    <item>
      <title>macro to check percentage of missing values in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-to-check-percentage-of-missing-values-in-a-dataset/m-p/676008#M203764</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;
&lt;P&gt;I wanted to check&amp;nbsp;percentage of missing values in a dataset by variable Category . I have used below code from other forum it worked and now i wanted same by variable&amp;nbsp; Category (which has values A,b,C).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc format;&lt;/P&gt;
&lt;P&gt;value $ missfmt ' '="Missing"&lt;/P&gt;
&lt;P&gt;other="Not Missing"&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;value nmissfmt . ="Missing"&lt;/P&gt;
&lt;P&gt;other="Not Missing"&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;
&lt;P&gt;format _numeric_ nmissfmt. _character_ $missfmt.;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc freq data=have;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But here's my macro. It needs work since I chopped it together from another macro I use, so not all the code in here is actually required.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro sum_missing(libname, dsetin, dsetout);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;*Delete old dataset;&lt;/P&gt;
&lt;P&gt;proc datasets nodetails nolist;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; delete &amp;amp;dsetout;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;*Upcase all macro variables to have consistency;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput ("libname", put(upcase("&amp;amp;libname."), $8.));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput ("dsetin", put(upcase("&amp;amp;dsetin."), $32.));&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;*Formats for missing for character and numeric variables;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc format;&lt;/P&gt;
&lt;P&gt;value $ missfmt ' '="Missing"&lt;/P&gt;
&lt;P&gt;other="Not Missing"&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;value nmissfmt . ="Missing"&lt;/P&gt;
&lt;P&gt;other="Not Missing"&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;*Copy dataset and apply missing formats to it;&lt;/P&gt;
&lt;P&gt;data step1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set &amp;amp;libname..&amp;amp;dsetin;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; format _character_ $missfmt. _numeric_ nmissfmt.;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;options mprint symbolgen;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;*Get variable list;&lt;/P&gt;
&lt;P&gt;proc sql noprint;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; select name&amp;nbsp; into : var_list separated by " "&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; from dictionary.columns&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; where upcase(libname) ="&amp;amp;libname"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; and upcase(memname)="&amp;amp;dsetin";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; *Get count of total number of observations into macro variable;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; select count(*) into : obs_count&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; from &amp;amp;libname..&amp;amp;dsetin.;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;*Start looping through the variable list here;&lt;/P&gt;
&lt;P&gt;%let i=1;&lt;/P&gt;
&lt;P&gt;%do %while (%scan(&amp;amp;var_list, &amp;amp;i, " ") ^=%str());&lt;/P&gt;
&lt;P&gt;%let var=%scan(&amp;amp;var_list, &amp;amp;i, " ");&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;*Get format of missing;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;/P&gt;
&lt;P&gt;set step1;&lt;/P&gt;
&lt;P&gt;call symput("var_fmt", vformat(&amp;amp;var));&lt;/P&gt;
&lt;P&gt;call symput("var_label", vlabel(&amp;amp;var));&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;*Get count of missing;&lt;/P&gt;
&lt;P&gt;proc freq data=step1 noprint;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; table &amp;amp;var/missing out=cross_tab1;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data cross_tab2;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set cross_tab1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; length variable $50.;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; category=put(&amp;amp;var, &amp;amp;var_fmt.);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; variable="&amp;amp;var_label.";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if _n_=1 and category='Not Missing' then do;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Number_Missing=&amp;amp;obs_count-count;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Percent_Missing=Number_Missing/&amp;amp;obs_count.;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; percent=percent/100;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else if _n_=1 and category='Missing' then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Number_Missing=count;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Percent_Missing=percent/100;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; format percent: percent10.1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; keep variable Number_Missing Percent_Missing;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc append base=&amp;amp;dsetout data=cross_tab2 force;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc datasets nodetails nolist;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; delete cross_tab1 cross_tab2;&lt;/P&gt;
&lt;P&gt;run; quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;*Increment counter;&lt;/P&gt;
&lt;P&gt;%let i=%eval(&amp;amp;i+1);&lt;/P&gt;
&lt;P&gt;%end; *Categorical;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc datasets nodetails nolist;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; delete step1;&lt;/P&gt;
&lt;P&gt;run; quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%mend;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can anyone please help ?&lt;/P&gt;</description>
      <pubDate>Tue, 11 Aug 2020 21:31:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-to-check-percentage-of-missing-values-in-a-dataset/m-p/676008#M203764</guid>
      <dc:creator>chennupriya</dc:creator>
      <dc:date>2020-08-11T21:31:59Z</dc:date>
    </item>
    <item>
      <title>Re: macro to check percentage of missing values in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-to-check-percentage-of-missing-values-in-a-dataset/m-p/676011#M203767</link>
      <description>&lt;P&gt;What is wrong with the code you are using?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why does this have to be a macro anyway? The non-macro code at the top of your message seems like it will work on any arbitrary data set.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Aug 2020 21:47:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-to-check-percentage-of-missing-values-in-a-dataset/m-p/676011#M203767</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-08-11T21:47:38Z</dc:date>
    </item>
    <item>
      <title>Re: macro to check percentage of missing values in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-to-check-percentage-of-missing-values-in-a-dataset/m-p/676013#M203768</link>
      <description>Hi ,&lt;BR /&gt;I wanted to check how do i apply  the code to check percentage missing of all variables by Category A Category B and Category C &lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Tue, 11 Aug 2020 22:00:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-to-check-percentage-of-missing-values-in-a-dataset/m-p/676013#M203768</guid>
      <dc:creator>chennupriya</dc:creator>
      <dc:date>2020-08-11T22:00:27Z</dc:date>
    </item>
    <item>
      <title>Re: macro to check percentage of missing values in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-to-check-percentage-of-missing-values-in-a-dataset/m-p/676016#M203770</link>
      <description>Your macro seems very similar to mine....including the name....&lt;A href="https://gist.github.com/statgeek/c3a9ddcb002c469e9d61" target="_blank"&gt;https://gist.github.com/statgeek/c3a9ddcb002c469e9d61&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;I've seen modified my approach as well and now use the one illustrated here. You'd need to change it to handle a two way table, since the original is designed for one way tables but that's easy if you understand what's happening.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://gist.github.com/statgeek/2de1faf1644dc8160fe721056202f111" target="_blank"&gt;https://gist.github.com/statgeek/2de1faf1644dc8160fe721056202f111&lt;/A&gt;</description>
      <pubDate>Tue, 11 Aug 2020 22:06:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-to-check-percentage-of-missing-values-in-a-dataset/m-p/676016#M203770</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-08-11T22:06:36Z</dc:date>
    </item>
    <item>
      <title>Re: macro to check percentage of missing values in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-to-check-percentage-of-missing-values-in-a-dataset/m-p/676018#M203772</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=have nlevels;
     by category;
     tables _all_ / missing;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 Aug 2020 22:11:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-to-check-percentage-of-missing-values-in-a-dataset/m-p/676018#M203772</guid>
      <dc:creator>Watts</dc:creator>
      <dc:date>2020-08-11T22:11:43Z</dc:date>
    </item>
    <item>
      <title>Re: macro to check percentage of missing values in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-to-check-percentage-of-missing-values-in-a-dataset/m-p/676019#M203773</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11383"&gt;@chennupriya&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Hi ,&lt;BR /&gt;I wanted to check how do i apply the code to check percentage missing of all variables by Category A Category B and Category C &lt;BR /&gt;&lt;BR /&gt;Thanks&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;What is a Category A (or Category B and Category C)? Is a variable named "Category" that sometimes has values of A?&lt;/P&gt;
&lt;P&gt;In which case your requirement is very unclear as when Category=A it cannot be missing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or are we supposed to identify which variables are involved because they sometimes have values of A, B or C?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or do you have a document somewhere that says variables AAA, PDQ and XYZ represent category A?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Aug 2020 22:13:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-to-check-percentage-of-missing-values-in-a-dataset/m-p/676019#M203773</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-08-11T22:13:31Z</dc:date>
    </item>
    <item>
      <title>Re: macro to check percentage of missing values in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-to-check-percentage-of-missing-values-in-a-dataset/m-p/676020#M203774</link>
      <description>wanted percenatges of XX , YY by Category &lt;BR /&gt;&lt;BR /&gt;XX	YY	Category&lt;BR /&gt;100	.	A&lt;BR /&gt;200	20	A&lt;BR /&gt;300	30	B&lt;BR /&gt;400	.	C&lt;BR /&gt;500	.	C&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 11 Aug 2020 22:18:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-to-check-percentage-of-missing-values-in-a-dataset/m-p/676020#M203774</guid>
      <dc:creator>chennupriya</dc:creator>
      <dc:date>2020-08-11T22:18:07Z</dc:date>
    </item>
    <item>
      <title>Re: macro to check percentage of missing values in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-to-check-percentage-of-missing-values-in-a-dataset/m-p/676022#M203776</link>
      <description>Thank you so much for the reply . Below is the output .But can i get same layout by variable Sex ?&lt;BR /&gt;&lt;BR /&gt;variable	N_Missing	N_Not Missing	PCT_Missing	PCT_Not Missing	Missing	Not Missing&lt;BR /&gt;Age	1	18	5.26	94.74	1 (  5.3%)	18 ( 94.7%)&lt;BR /&gt;Height	4	15	21.05	78.95	4 ( 21.1%)	15 ( 78.9%)&lt;BR /&gt;Name		19		100.00		19 (  100%)&lt;BR /&gt;Sex	4	15	21.05	78.95	4 ( 21.1%)	15 ( 78.9%)&lt;BR /&gt;Weight	4	15	21.05	78.95	4 ( 21.1%)	15 ( 78.9%)&lt;BR /&gt;</description>
      <pubDate>Tue, 11 Aug 2020 22:24:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-to-check-percentage-of-missing-values-in-a-dataset/m-p/676022#M203776</guid>
      <dc:creator>chennupriya</dc:creator>
      <dc:date>2020-08-11T22:24:36Z</dc:date>
    </item>
    <item>
      <title>Re: macro to check percentage of missing values in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-to-check-percentage-of-missing-values-in-a-dataset/m-p/676023#M203777</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11383"&gt;@chennupriya&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;BR /&gt;I wanted to check how do i apply the code to check percentage missing of all variables by Category A Category B and Category C &lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The first step in any macro writing ought to be to create working SAS code without macros and without macro variables, for a single data set. Once you have done that, turning the results into a macro will be relatively simple. But it doesn't appear you have done that yet.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Aug 2020 22:36:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-to-check-percentage-of-missing-values-in-a-dataset/m-p/676023#M203777</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-08-11T22:36:07Z</dc:date>
    </item>
    <item>
      <title>Re: macro to check percentage of missing values in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-to-check-percentage-of-missing-values-in-a-dataset/m-p/676024#M203778</link>
      <description>&lt;P&gt;That could look something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Proc tabulate data=have;&lt;BR /&gt;   class category;&lt;BR /&gt;   class xx yy/ missing;&lt;BR /&gt;   format xx yy nmissfmt. ;
   tables category, &lt;BR /&gt;          (xx yy)*rowpctn&lt;BR /&gt;         /&lt;BR /&gt;   ;

run;&lt;/PRE&gt;
&lt;P&gt;The output table would have a row for each value of Category and a column for "Missing" and "Not missing" for XX and YY and a percentage, The ROWPCTN is a percentage of the "row", the values of XX and YY separately. The format makes two columns. The default column heading will include the statistic ROWPCTN. Tabulate supports other percentages such as PCTN, percent of all the row/col combinations of variables crossing, COLPCTN which would be the Category percentage for each value of XX or YY. &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note: By default Proc Tabulate will remove any record with a missing value for any of the CLASS variables. So we have two class statements. If Category has missing values the records would be removed and if you want them you would add the / missing option to keep them in the table as well.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Aug 2020 22:44:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-to-check-percentage-of-missing-values-in-a-dataset/m-p/676024#M203778</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-08-11T22:44:49Z</dc:date>
    </item>
    <item>
      <title>Re: macro to check percentage of missing values in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-to-check-percentage-of-missing-values-in-a-dataset/m-p/676025#M203779</link>
      <description>&lt;P&gt;Of course, modify the macro or code to handle a grouping variable. This does mean customizing the code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This can get you started but I don't have time to finish it up or generalize it at this point.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data class;
set sashelp.class;
if age in (13, 14) then call missing(name, weight, height);
run;
proc format;

value $ missfmt ' '="Missing"

other="Not Missing"

;

value nmissfmt . ="Missing"

other="Not Missing"

;

run;

 
ods output crosstabfreqs=summary;
proc freq data=class;
table sex*(name weight height age) / missing;
format _numeric_ nmissfmt. name $missfmt.;
run;




data long;
	length variable $32. variable_value $50.;
	set summary;
	
	if missing(sex) then delete;
	
	Variable=scan(table, 2, '*');
	Variable_Value=strip(trim(vvaluex(variable)));
	presentation=catt(frequency, " (", trim(put(percent/100, percent7.1)), ")");
	keep sex variable  variable_value frequency percent presentation;
	label variable='Variable' variable_value='Variable Value';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Aug 2020 22:46:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-to-check-percentage-of-missing-values-in-a-dataset/m-p/676025#M203779</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-08-11T22:46:20Z</dc:date>
    </item>
    <item>
      <title>Re: macro to check percentage of missing values in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-to-check-percentage-of-missing-values-in-a-dataset/m-p/676026#M203780</link>
      <description>Thank you so much for the reply . I have tried this  what if i have 100's of variables and not just three and can also get the count along with the percentage ?</description>
      <pubDate>Tue, 11 Aug 2020 22:59:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-to-check-percentage-of-missing-values-in-a-dataset/m-p/676026#M203780</guid>
      <dc:creator>chennupriya</dc:creator>
      <dc:date>2020-08-11T22:59:21Z</dc:date>
    </item>
    <item>
      <title>Re: macro to check percentage of missing values in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-to-check-percentage-of-missing-values-in-a-dataset/m-p/676029#M203781</link>
      <description>Also , i have both character and numeric variables in the Dataset</description>
      <pubDate>Tue, 11 Aug 2020 23:15:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-to-check-percentage-of-missing-values-in-a-dataset/m-p/676029#M203781</guid>
      <dc:creator>chennupriya</dc:creator>
      <dc:date>2020-08-11T23:15:52Z</dc:date>
    </item>
    <item>
      <title>Re: macro to check percentage of missing values in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-to-check-percentage-of-missing-values-in-a-dataset/m-p/676031#M203782</link>
      <description>&lt;P&gt;You can use variable lists on CLASS, Format and Tables statements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc tabulate data =have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; class _numeric_ _character_ /missing;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; format _numeric_ nmissfmt _character_ $missfmt. ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; tables _numeric_ _character_ ,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; category*(n colpctn)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This changes the row/column order from the first because if you have "100's" of variables then across is extremely likely to be very hard to use.&lt;/P&gt;
&lt;P&gt;This will create a combination of category with itself.&lt;/P&gt;
&lt;P&gt;There are a number of statistics that you can request. That is what the documentaiton is for.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Actually if this had been my data I likely would have created indicator variables with a value of 1 for not missing and then 0 for missing (or vice versa) and then use statistics Sum (total is number of 1's) and Mean(decimal percentage of 1's).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But very few of my data sets have 100's of variables that need checking.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Aug 2020 23:35:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-to-check-percentage-of-missing-values-in-a-dataset/m-p/676031#M203782</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-08-11T23:35:46Z</dc:date>
    </item>
    <item>
      <title>Re: macro to check percentage of missing values in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-to-check-percentage-of-missing-values-in-a-dataset/m-p/676034#M203783</link>
      <description>Hi ,&lt;BR /&gt;I ran above code but i get below error &lt;BR /&gt;&lt;BR /&gt;24         proc tabulate data =test;&lt;BR /&gt;25            class _numeric_ _character_ /missing;&lt;BR /&gt;26            format _numeric_ nmissfmt _character_ $missfmt. ;&lt;BR /&gt;ERROR: You are trying to use the character format $MISSFMT with the numeric variable XX in data set WORK.TEST.&lt;BR /&gt;ERROR: You are trying to use the character format $MISSFMT with the numeric variable YY in data set WORK.TEST.&lt;BR /&gt;WARNING: Variable NMISSFMT not found in data set WORK.TEST.&lt;BR /&gt;27            tables _numeric_ _character_ ,&lt;BR /&gt;28                      category*(n rowpctn)&lt;BR /&gt;29                      /&lt;BR /&gt;30             ;&lt;BR /&gt;31         run;</description>
      <pubDate>Tue, 11 Aug 2020 23:46:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-to-check-percentage-of-missing-values-in-a-dataset/m-p/676034#M203783</guid>
      <dc:creator>chennupriya</dc:creator>
      <dc:date>2020-08-11T23:46:42Z</dc:date>
    </item>
    <item>
      <title>Re: macro to check percentage of missing values in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-to-check-percentage-of-missing-values-in-a-dataset/m-p/676056#M203788</link>
      <description>&lt;P&gt;Because you left the period out of the format specification instead of trying to apply two different formats to two different lists of variables you are trying to apply one format to all of the variable, including one that does not exist.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Aug 2020 02:52:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-to-check-percentage-of-missing-values-in-a-dataset/m-p/676056#M203788</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-08-12T02:52:21Z</dc:date>
    </item>
    <item>
      <title>Re: macro to check percentage of missing values in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-to-check-percentage-of-missing-values-in-a-dataset/m-p/676122#M203821</link>
      <description>&lt;P&gt;It is easy for PROC SQL.&lt;/P&gt;
&lt;P&gt;Make a macro to make the following code streamline .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
set sashelp.heart;
if ranuni(1) &amp;lt; 0.2 then call missing(AgeAtStart,status);
run;

proc sql;
create table want as
select sex,
 nmiss(AgeAtStart)/count(*) as nmiss_per_AgeAtStart,
 nmiss(status)/count(*) as nmiss_per_status,
 nmiss(height)/count(*) as nmiss_per_height
from have
 group by sex;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Aug 2020 12:11:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-to-check-percentage-of-missing-values-in-a-dataset/m-p/676122#M203821</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-08-12T12:11:12Z</dc:date>
    </item>
    <item>
      <title>Re: macro to check percentage of missing values in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-to-check-percentage-of-missing-values-in-a-dataset/m-p/676123#M203822</link>
      <description>&lt;A href="https://www.sas.com/content/dam/SAS/support/en/sas-global-forum-proceedings/2020/4737-2020.pdf" target="_blank"&gt;https://www.sas.com/content/dam/SAS/support/en/sas-global-forum-proceedings/2020/4737-2020.pdf&lt;/A&gt;</description>
      <pubDate>Wed, 12 Aug 2020 12:15:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-to-check-percentage-of-missing-values-in-a-dataset/m-p/676123#M203822</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-08-12T12:15:24Z</dc:date>
    </item>
    <item>
      <title>Re: macro to check percentage of missing values in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-to-check-percentage-of-missing-values-in-a-dataset/m-p/676376#M203930</link>
      <description>Thank you so much for all your help</description>
      <pubDate>Thu, 13 Aug 2020 03:20:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-to-check-percentage-of-missing-values-in-a-dataset/m-p/676376#M203930</guid>
      <dc:creator>chennupriya</dc:creator>
      <dc:date>2020-08-13T03:20:50Z</dc:date>
    </item>
    <item>
      <title>Re: macro to check percentage of missing values in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-to-check-percentage-of-missing-values-in-a-dataset/m-p/676377#M203931</link>
      <description>Thank you for all your help</description>
      <pubDate>Thu, 13 Aug 2020 03:21:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-to-check-percentage-of-missing-values-in-a-dataset/m-p/676377#M203931</guid>
      <dc:creator>chennupriya</dc:creator>
      <dc:date>2020-08-13T03:21:54Z</dc:date>
    </item>
  </channel>
</rss>

