<?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: Check for variable in data step in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Check-for-variable-in-data-step/m-p/595136#M171159</link>
    <description>Would like to check for non missing values for all the rows&lt;BR /&gt;</description>
    <pubDate>Wed, 09 Oct 2019 17:14:32 GMT</pubDate>
    <dc:creator>David_Billa</dc:creator>
    <dc:date>2019-10-09T17:14:32Z</dc:date>
    <item>
      <title>Check for variable in data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-for-variable-in-data-step/m-p/594971#M171083</link>
      <description>&lt;P&gt;Could you please help me write a condition to check for one variable in a dataset using data step? I don't want to use SASHELP.VCOLUMN. Is there any function to tackle to check for variable?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I just need only the condition to check if variable exists in a dataset.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Oct 2019 08:02:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-for-variable-in-data-step/m-p/594971#M171083</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2019-10-09T08:02:27Z</dc:date>
    </item>
    <item>
      <title>Re: Check for variable in data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-for-variable-in-data-step/m-p/594972#M171084</link>
      <description>&lt;P&gt;See&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;s solution in the thread&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/How-to-know-whether-a-variable-exists-in-a-dataset/td-p/120083" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/How-to-know-whether-a-variable-exists-in-a-dataset/td-p/120083&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Oct 2019 08:08:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-for-variable-in-data-step/m-p/594972#M171084</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-10-09T08:08:18Z</dc:date>
    </item>
    <item>
      <title>Re: Check for variable in data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-for-variable-in-data-step/m-p/594973#M171085</link>
      <description>Thanks, any other ways?&lt;BR /&gt;</description>
      <pubDate>Wed, 09 Oct 2019 08:14:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-for-variable-in-data-step/m-p/594973#M171085</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2019-10-09T08:14:32Z</dc:date>
    </item>
    <item>
      <title>Re: Check for variable in data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-for-variable-in-data-step/m-p/595072#M171121</link>
      <description>&lt;P&gt;You can loop through the variables using CALL VNEXT().&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292396"&gt;@David_Billa&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thanks, any other ways?&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Oct 2019 14:43:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-for-variable-in-data-step/m-p/595072#M171121</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-10-09T14:43:04Z</dc:date>
    </item>
    <item>
      <title>Re: Check for variable in data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-for-variable-in-data-step/m-p/595124#M171152</link>
      <description>How to check for the data if the variable exists?&lt;BR /&gt;&lt;BR /&gt;I would like to know whether the variable exists and if exists whether&lt;BR /&gt;there is a data available or not?&lt;BR /&gt;</description>
      <pubDate>Wed, 09 Oct 2019 16:12:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-for-variable-in-data-step/m-p/595124#M171152</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2019-10-09T16:12:32Z</dc:date>
    </item>
    <item>
      <title>Re: Check for variable in data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-for-variable-in-data-step/m-p/595126#M171154</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292396"&gt;@David_Billa&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;How to check for the data if the variable exists?&lt;BR /&gt;&lt;BR /&gt;I would like to know whether the variable exists and if exists whether&lt;BR /&gt;there is a data available or not?&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That is a totally different question.&amp;nbsp; Do you want to test if the variable EVER has a non-missing value?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also what do you mean by test in a data step?&amp;nbsp; Once you reference a variable in the code of a datastep the compiler will see the reference and create the variable for you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a data step that will test if a variable ever has any missing values and generate a macro variable you can use to drive some future decisions.&amp;nbsp; This will test the dataset HAVE for the variable X and create the macro variable X_EXISTS with either 0 or 1 as the value.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  if _n_=1 then call symputx('x_exists','0');
  set have ;
  if not missing(X) then do;
    call symputx('x_exists','1');
    stop;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 Oct 2019 16:21:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-for-variable-in-data-step/m-p/595126#M171154</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-10-09T16:21:49Z</dc:date>
    </item>
    <item>
      <title>Re: Check for variable in data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-for-variable-in-data-step/m-p/595129#M171156</link>
      <description>Yes, I want to test whethe the variable has a non missing value&lt;BR /&gt;</description>
      <pubDate>Wed, 09 Oct 2019 16:28:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-for-variable-in-data-step/m-p/595129#M171156</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2019-10-09T16:28:32Z</dc:date>
    </item>
    <item>
      <title>Re: Check for variable in data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-for-variable-in-data-step/m-p/595134#M171158</link>
      <description>Datasets typically have multiple records. When you say non missing value, is that for a specific row or all rows? If you have 10 records, 6 missing and 4 non missing what happens?</description>
      <pubDate>Wed, 09 Oct 2019 17:10:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-for-variable-in-data-step/m-p/595134#M171158</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-10-09T17:10:59Z</dc:date>
    </item>
    <item>
      <title>Re: Check for variable in data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-for-variable-in-data-step/m-p/595136#M171159</link>
      <description>Would like to check for non missing values for all the rows&lt;BR /&gt;</description>
      <pubDate>Wed, 09 Oct 2019 17:14:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-for-variable-in-data-step/m-p/595136#M171159</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2019-10-09T17:14:32Z</dc:date>
    </item>
    <item>
      <title>Re: Check for variable in data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-for-variable-in-data-step/m-p/595144#M171166</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292396"&gt;@David_Billa&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Would like to check for non missing values for all the rows&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Please create examples and what you want.&lt;/P&gt;
&lt;P&gt;For example here is code that checks every value of X in dataset HAVE and sets to dataset variables ANY_MISSING and ANY_POPULATED.&amp;nbsp; It just writes them to the log , but you could make macro variables if you want.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  retain any_missing 0 any_populated 0;
  if eof then put any_missing= any_populated=;
  set have end=eof;
  if missing(X) then any_missing=1;
  else any_populated=1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;So for 2 binary variables there are 4 possible combinations.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;any_missing=0 and any_populated=0 - means the dataset has NO observations.&lt;/P&gt;
&lt;P&gt;any_missing=1 and any_populated=0 - means ALL of the observations have missing values for X.&lt;/P&gt;
&lt;P&gt;any_missing=0 and any_populated=1 - means ALL of the observations have non-missing values for X, that is NONE of the observations have missing values of X.&lt;/P&gt;
&lt;P&gt;any_missing=1 and any_populated=1 - means some observations have missing values for X and some have non-missing values of X.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Oct 2019 17:34:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-for-variable-in-data-step/m-p/595144#M171166</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-10-09T17:34:49Z</dc:date>
    </item>
    <item>
      <title>Re: Check for variable in data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-for-variable-in-data-step/m-p/595146#M171168</link>
      <description>Probably overkill for what you need but here's some code that prepares a few variants of a missing report on your data. &lt;BR /&gt;&lt;BR /&gt;You can run the code directly from GitHub and see the results and the different summary results.&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>Wed, 09 Oct 2019 17:38:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-for-variable-in-data-step/m-p/595146#M171168</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-10-09T17:38:35Z</dc:date>
    </item>
  </channel>
</rss>

