<?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:Missing fields in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/finding-columns-that-are-blank/m-p/936820#M83570</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset of customer salary details past 12 months need to know in past 12 months continue blank cells.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;how ican find out&lt;/P&gt;</description>
    <pubDate>Tue, 23 Jul 2024 17:20:59 GMT</pubDate>
    <dc:creator>ahmedjabirpt</dc:creator>
    <dc:date>2024-07-23T17:20:59Z</dc:date>
    <item>
      <title>finding columns that are blank</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/finding-columns-that-are-blank/m-p/534843#M73892</link>
      <description>&lt;P&gt;How can I find columns that are completely blank in a data set that I created by importing a csv file? Running PROC FREQ on all variables is not practical due to file size.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2019 14:01:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/finding-columns-that-are-blank/m-p/534843#M73892</guid>
      <dc:creator>GreggB</dc:creator>
      <dc:date>2019-02-12T14:01:48Z</dc:date>
    </item>
    <item>
      <title>Re: finding columns that are blank</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/finding-columns-that-are-blank/m-p/534858#M73893</link>
      <description>&lt;P&gt;This approach does 1 pass through your data with a datastep, and then some cleanup. If it usually takes 20 minutes for one pass through your data, this may take about as long. This assumes that your field names are all 26 chars or less (I add the text "_count" to the field names):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*my practice dataset;
data temp;
	set sashelp.cars;
	call missing(make, model, cylinders);
run;

*your table;
%let table_name=work.temp;

proc contents data=&amp;amp;table_name noprint out=work.contents;
run;
proc sql noprint;
	select name into :fields separated by ' '
	from work.contents;
quit;
%put &amp;amp;fields;

%macro find_missing;
	%let to_loop = %sysfunc(countw(&amp;amp;fields)); 
	data result;
		set &amp;amp;table_name end=last;
		retain %do i = 1 %to &amp;amp;to_loop;
				   %scan(&amp;amp;fields,&amp;amp;i)_count	
			   %end;
			   0;
		%do i = 1 %to &amp;amp;to_loop;
		   if not missing(%scan(&amp;amp;fields,&amp;amp;i)) then %scan(&amp;amp;fields,&amp;amp;i)_count +1;
	    %end;
		if last then output;
	run;
%mend;
%find_missing

*rotate dataset to make it look nice;
proc transpose data=result out=rotated(where=(COL1=0));
run;
*and restore normal var names.;
data final;
	set rotated;
	length field $32;
	*cut the "_count" off of &amp;lt;variable name&amp;gt;_count;
	field = substr(_name_,1,length(_name_)-6);
	keep field;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Results are in the final dataset.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2019 14:40:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/finding-columns-that-are-blank/m-p/534858#M73893</guid>
      <dc:creator>noling</dc:creator>
      <dc:date>2019-02-12T14:40:57Z</dc:date>
    </item>
    <item>
      <title>Re: finding columns that are blank</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/finding-columns-that-are-blank/m-p/534861#M73894</link>
      <description>&lt;P&gt;ODS Select can restrict which tables are generated. The Proc Freq NLEVELS may be the briefest approach:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data example;
   do i= 1 to 10;
    x=.;
    output;
   end;
run;

ods select nlevels;
proc freq data=example nlevels;
run;&lt;/PRE&gt;
&lt;P&gt;A variable with 0 Nonmissing Levels would have all values missing.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2019 15:01:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/finding-columns-that-are-blank/m-p/534861#M73894</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-02-12T15:01:45Z</dc:date>
    </item>
    <item>
      <title>Re: finding columns that are blank</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/finding-columns-that-are-blank/m-p/534873#M73895</link>
      <description>&lt;P&gt;Sir&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp; once again you are proving you are genius. If you have a moment, can you offer a couple of notes on how that works nlevels. I just saw the doc and I got more confused. A request to you at your own convenience. Thanks&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, would that work for char var?&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2019 15:23:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/finding-columns-that-are-blank/m-p/534873#M73895</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-02-12T15:23:29Z</dc:date>
    </item>
    <item>
      <title>Re: finding columns that are blank</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/finding-columns-that-are-blank/m-p/534876#M73896</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/115150"&gt;@noling&lt;/a&gt; you can avoid the proc contents step by pulling the variable names directly from dictionary.columns.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2019 15:31:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/finding-columns-that-are-blank/m-p/534876#M73896</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-02-12T15:31:14Z</dc:date>
    </item>
    <item>
      <title>Re: finding columns that are blank</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/finding-columns-that-are-blank/m-p/534882#M73897</link>
      <description>&lt;P&gt;I would bet that imported variables that are always blank must be numeric.&amp;nbsp; So let's take the easy route:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc summary data=have;&lt;/P&gt;
&lt;P&gt;var _numeric_;&lt;/P&gt;
&lt;P&gt;output out=maxvals (drop=_type_ _freq_) max=;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That gives you the maximum value for each numeric variable, but uses the original variable name to hold the result.&amp;nbsp; There are a few structures that might be considered a "list".&amp;nbsp; One way to proceed from there:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data always_missing;&lt;/P&gt;
&lt;P&gt;length var $ 32;&lt;/P&gt;
&lt;P&gt;set maxvals;&lt;/P&gt;
&lt;P&gt;array nums {*} _numeric_;&lt;/P&gt;
&lt;P&gt;do _n_=1 to dim(nums);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;if nums{_n_} = . then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; var = vname(nums{_n_});&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; output;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;end;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2019 15:43:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/finding-columns-that-are-blank/m-p/534882#M73897</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-02-12T15:43:52Z</dc:date>
    </item>
    <item>
      <title>Re: finding columns that are blank</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/finding-columns-that-are-blank/m-p/534884#M73898</link>
      <description>&lt;P&gt;Basically the NLEVELS option creates a table of counts of unique values. In the example above:&lt;/P&gt;
&lt;PRE&gt;          Number of Variable Levels

                         Missing    Nonmissing
Variable      Levels      Levels        Levels
----------------------------------------------
i                 10           0            10
x                  1           1             0

&lt;/PRE&gt;
&lt;P&gt;The variable I has 10 unique values (Levels) all non-missing, x has 1 unique value, with 1 missing level and no non-missing levels.&lt;/P&gt;
&lt;P&gt;The "Missing Levels" can be important if you use the special missing .A through .Z.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In another example with data:&lt;/P&gt;
&lt;PRE&gt;data example;
   do i= 1 to 10;
    x=.;
    output;
   end;
   do i= 1 to 10;
      if mod(i,3)=0 then x=.A;
      output;
      if mod(i,4)=0 then x=i;
      else x=.;
      output;
   end;
run;&lt;/PRE&gt;
&lt;P&gt;The result would be:&lt;/P&gt;
&lt;PRE&gt;          Number of Variable Levels

                         Missing    Nonmissing
Variable      Levels      Levels        Levels
----------------------------------------------
i                 10           0            10
x                  4           2             2

&lt;/PRE&gt;
&lt;P&gt;Which again shows I with 10 unique values even though they are repeated and no nonmissing. X now shows 4 levels because it has values of ., .A (special missing), 4 and 8. The missing levels shows 2 because of the use of .A as well as simple . missing, as well as showing that 2 of the levels are nonmissing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This can also be used to check if the variable values are repeated by comparing to the number of records in the dataset. If a value should be unique and present for each record then the nonmissing levels should equal the number of records in a set (easily found in the Log from the number of observations read.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2019 15:46:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/finding-columns-that-are-blank/m-p/534884#M73898</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-02-12T15:46:59Z</dc:date>
    </item>
    <item>
      <title>Re: finding columns that are blank</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/finding-columns-that-are-blank/m-p/534890#M73899</link>
      <description>&lt;P&gt;Thank you sir&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2019 15:52:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/finding-columns-that-are-blank/m-p/534890#M73899</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-02-12T15:52:07Z</dc:date>
    </item>
    <item>
      <title>Re: finding columns that are blank</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/finding-columns-that-are-blank/m-p/534901#M73901</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I would bet that imported variables that are always blank must be numeric.&amp;nbsp; So let's take the easy route:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Most of the CSV I have imported using Proc Import with all&amp;nbsp;missing values end up with $1. informats for those columns.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2019 16:15:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/finding-columns-that-are-blank/m-p/534901#M73901</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-02-12T16:15:26Z</dc:date>
    </item>
    <item>
      <title>Re: finding columns that are blank</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/finding-columns-that-are-blank/m-p/534956#M73907</link>
      <description>&lt;P&gt;Applying a FORMAT to all variable such that all non-missing values are considered equal should&amp;nbsp;make it a bit faster.&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;
   call missing(height,sex);
   run;
proc format ;
	value $missfmt    ' '="Missing" other="Not Missing";
	value missfmt  ._-.Z ="Missing" other="Not Missing";
   run;
ods select none;
proc freq data=class nlevels;
	format _numeric_ missfmt. _character_ $missfmt.;
   ods output nlevels=nlevels;
   run;
ods select all;
data nlevels;
   length TableVar $32 NLevels NMissLevels NNonMissLevels 8;  
   set nlevels;
   if NNonMissLevels eq 0 then Flag=1;
   run;
proc print;
   run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 419px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/27092i6608428BB8F11139/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2019 18:53:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/finding-columns-that-are-blank/m-p/534956#M73907</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2019-02-12T18:53:24Z</dc:date>
    </item>
    <item>
      <title>Re: finding columns that are blank</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/finding-columns-that-are-blank/m-p/535008#M73909</link>
      <description>&lt;P&gt;If the number of variables is large, but only a few of them are suspected to be completely or mostly blank, I would first draw a reasonably sized random sample from the dataset in order to determine those few "candidate" variables and then restrict the full analysis (e.g. with NLEVELS) accordingly.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2019 21:01:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/finding-columns-that-are-blank/m-p/535008#M73909</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2019-02-12T21:01:39Z</dc:date>
    </item>
    <item>
      <title>Re: finding columns that are blank</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/finding-columns-that-are-blank/m-p/535013#M73910</link>
      <description>&lt;P&gt;Sir&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp; &amp;nbsp;You've got me interested.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"&lt;SPAN&gt;I would&lt;STRONG&gt; first draw a reasonably sized random sample f&lt;/STRONG&gt;rom the dataset in order to determine those few "candidate" variables&amp;nbsp;"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Can you explain this a bit further when you have some time plz&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2019 21:07:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/finding-columns-that-are-blank/m-p/535013#M73910</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-02-12T21:07:04Z</dc:date>
    </item>
    <item>
      <title>Re: finding columns that are blank</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/finding-columns-that-are-blank/m-p/535024#M73911</link>
      <description>&lt;P&gt;I was just thinking: If there were, say, 10 million observations with a total of 1000 variables, but only 5 of them were either sparsely populated or perhaps completely blank, why should we spend computing time to find out that the remaining 995 variables have 7654321, 5566778, ... distinct non-missing levels, respectively?&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2019 21:22:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/finding-columns-that-are-blank/m-p/535024#M73911</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2019-02-12T21:22:17Z</dc:date>
    </item>
    <item>
      <title>Re: finding columns that are blank</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/finding-columns-that-are-blank/m-p/536428#M73966</link>
      <description>&lt;P&gt;You can do it with a datastep, like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  retain a . b 3 t 5 j ' ' name 'øfdø';
  do i=1 to 300;
    output;
    end;
run;

data missingvars;
  if 0 then set have;
  array nums _numeric_;
  array char _character_;
  type='N'; /* numeric */
  do _N_=1 to dim(nums);
    name=vname(nums(_N_));
    dsid=open(catt('have(where=(',name,' is not null))'));
    select(fetch(dsid));
      when(-1)  /* no data */
        output;
      when(0); /* data read OK */
      otherwise do;
        msg=sysmsg();
        put msg=;
        end;
      end;
    dsid=close(dsid);
    end;
  type='C'; /* numeric */
  do _N_=1 to dim(char);
    name=vname(char(_N_));
    dsid=open(catt('have(where=(',name,' is not null))'));
    select(fetch(dsid));
      when(-1)  /* no data */
        output;
      when(0); /* data read OK */
      otherwise do;
        msg=sysmsg();
        put msg=;
        end;
      end;
    dsid=close(dsid);
    end;
  stop;
  keep type name;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This approach is probably relatively fast, as it just uses a where clause to look for non-missing values of each variable.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Feb 2019 10:32:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/finding-columns-that-are-blank/m-p/536428#M73966</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2019-02-18T10:32:08Z</dc:date>
    </item>
    <item>
      <title>Re:Missing fields</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/finding-columns-that-are-blank/m-p/936820#M83570</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset of customer salary details past 12 months need to know in past 12 months continue blank cells.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;how ican find out&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jul 2024 17:20:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/finding-columns-that-are-blank/m-p/936820#M83570</guid>
      <dc:creator>ahmedjabirpt</dc:creator>
      <dc:date>2024-07-23T17:20:59Z</dc:date>
    </item>
    <item>
      <title>Re: Re:Missing fields</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/finding-columns-that-are-blank/m-p/936821#M83571</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/467527"&gt;@ahmedjabirpt&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a dataset of customer salary details past 12 months need to know in past 12 months continue blank cells.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;how ican find out&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Please start a new thread, and then describe your problem completely from the beginning. Provide example data that we can use.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jul 2024 17:24:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/finding-columns-that-are-blank/m-p/936821#M83571</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-07-23T17:24:30Z</dc:date>
    </item>
  </channel>
</rss>

