<?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 checking null values for the variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/checking-null-values-for-the-variables/m-p/522423#M141826</link>
    <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset which consists of 3 columns name,memname and libname&amp;nbsp;&lt;/P&gt;&lt;P&gt;memname consists of list of datasets and name consists of list variables associated to corresponding to dataset.&lt;/P&gt;&lt;P&gt;Kindly help me how to check whether the value of variable to particular dataset is null or not and populate a status varaible coulmn if value exists to a variable&lt;/P&gt;&lt;P&gt;only there are two libraries&lt;/P&gt;&lt;P&gt;ex.&lt;/P&gt;&lt;P&gt;memname: x1,x2,x3&lt;/P&gt;&lt;P&gt;name: v1,v2,v3&lt;/P&gt;&lt;P&gt;libname: l1,l2,l1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;how to check whether vi is null or not&lt;/P&gt;</description>
    <pubDate>Wed, 19 Dec 2018 04:49:53 GMT</pubDate>
    <dc:creator>niteshbharadwaj</dc:creator>
    <dc:date>2018-12-19T04:49:53Z</dc:date>
    <item>
      <title>checking null values for the variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/checking-null-values-for-the-variables/m-p/522423#M141826</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset which consists of 3 columns name,memname and libname&amp;nbsp;&lt;/P&gt;&lt;P&gt;memname consists of list of datasets and name consists of list variables associated to corresponding to dataset.&lt;/P&gt;&lt;P&gt;Kindly help me how to check whether the value of variable to particular dataset is null or not and populate a status varaible coulmn if value exists to a variable&lt;/P&gt;&lt;P&gt;only there are two libraries&lt;/P&gt;&lt;P&gt;ex.&lt;/P&gt;&lt;P&gt;memname: x1,x2,x3&lt;/P&gt;&lt;P&gt;name: v1,v2,v3&lt;/P&gt;&lt;P&gt;libname: l1,l2,l1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;how to check whether vi is null or not&lt;/P&gt;</description>
      <pubDate>Wed, 19 Dec 2018 04:49:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/checking-null-values-for-the-variables/m-p/522423#M141826</guid>
      <dc:creator>niteshbharadwaj</dc:creator>
      <dc:date>2018-12-19T04:49:53Z</dc:date>
    </item>
    <item>
      <title>Re: checking null values for the variables [how to improve your question]</title>
      <link>https://communities.sas.com/t5/SAS-Programming/checking-null-values-for-the-variables/m-p/522424#M141827</link>
      <description>&lt;P&gt;Hello &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/193319"&gt;@niteshbharadwaj&lt;/a&gt;,&lt;/P&gt;&lt;BR /&gt; &lt;P&gt;Your question requires more details before experts can help.&amp;nbsp;Can you revise your question to include more information?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Review this checklist:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Specify a meaningful subject line for your topic.&amp;nbsp; Avoid generic subjects like "need help," "SAS query," or "urgent."&lt;/LI&gt;
&lt;LI&gt;When appropriate, provide sample data in text or DATA step format.&amp;nbsp; See &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;this article for one method&lt;/A&gt;&amp;nbsp;you can use.&lt;/LI&gt;
&lt;LI&gt;If you're encountering an error in SAS, include the SAS log or a screenshot of the error condition.&amp;nbsp;Use the&amp;nbsp;&lt;STRONG&gt;Photos&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;button to include the image in your message.&lt;BR /&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" style="width: 279px;"&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/16608i91A52F817EAC9A69/image-dimensions/279x150?v=1.0" width="279" height="150" alt="use_buttons.png" title="use_buttons.png" /&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;It also helps to include an example (table or picture) of the result that you're trying to achieve.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;To edit your original message, select the "blue gear" icon at the top of the message and select&amp;nbsp;&lt;STRONG&gt;Edit Message&lt;/STRONG&gt;.&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;From there you can adjust the title and add more details to the body of the message.&amp;nbsp; Or, simply reply to this message with any additional information you can supply.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" style="width: 229px;"&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/16605iAC020BC79315B045/image-size/large?v=1.0&amp;amp;px=600" alt="edit_post.png" title="edit_post.png" /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;SAS experts are eager to help -- help&amp;nbsp;&lt;EM&gt;them&lt;/EM&gt; by providing as much detail as you can.&lt;/P&gt; &lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-style:italic;font-size:smaller;"&gt;This prewritten response was triggered for you by fellow SAS Support Communities member &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&lt;/SPAN&gt;&lt;/P&gt;.</description>
      <pubDate>Wed, 19 Dec 2018 04:44:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/checking-null-values-for-the-variables/m-p/522424#M141827</guid>
      <dc:creator>Community_Guide</dc:creator>
      <dc:date>2018-12-19T04:44:53Z</dc:date>
    </item>
    <item>
      <title>Re: checking null values for the variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/checking-null-values-for-the-variables/m-p/522461#M141851</link>
      <description>&lt;P&gt;Post example test data in the form of a datastep:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And show what you want the output from that test data to be.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can loop over the datasets and run a proc freq on _character_ data, and proc means on _numeric_ data, which will give you a dataset of results.&amp;nbsp; Or you can generate code from it.&amp;nbsp; Neither way is however great.&amp;nbsp; What value is there in this?&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Dec 2018 09:36:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/checking-null-values-for-the-variables/m-p/522461#M141851</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-12-19T09:36:58Z</dc:date>
    </item>
    <item>
      <title>Re: checking null values for the variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/checking-null-values-for-the-variables/m-p/522464#M141852</link>
      <description>&lt;P&gt;My dataset abcd has 3 coloumns:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;memname&amp;nbsp; name&amp;nbsp; &amp;nbsp;libname&lt;/P&gt;&lt;P&gt;x1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;v1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; lib1&lt;/P&gt;&lt;P&gt;x1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; v2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;lib1&lt;/P&gt;&lt;P&gt;x2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;v3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;lib2&lt;/P&gt;&lt;P&gt;x3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;v4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; lib1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is how my dataset abcd looks like,&lt;/P&gt;&lt;P&gt;here memname varaible consists of list of datasets i.e. x1,x2,x3 are datasets&lt;/P&gt;&lt;P&gt;name variable consists of list of variables associated to it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;how to check whether varaiable v1 of dataset x1 is null or not.&lt;/P&gt;&lt;P&gt;Repeating the same process till end of the table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and popultae a field status =0 for null and status =1 for not null in abcd dataset again&lt;/P&gt;</description>
      <pubDate>Wed, 19 Dec 2018 09:45:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/checking-null-values-for-the-variables/m-p/522464#M141852</guid>
      <dc:creator>niteshbharadwaj</dc:creator>
      <dc:date>2018-12-19T09:45:17Z</dc:date>
    </item>
    <item>
      <title>Re: checking null values for the variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/checking-null-values-for-the-variables/m-p/522465#M141853</link>
      <description>&lt;P&gt;Again,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Post example test data in the form of a datastep:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We are not here to type in test data or guess what it looks like (and please supply test data for the ones to be checked, just one is fine).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;At a guess:&lt;/P&gt;
&lt;PRE&gt;data have;&lt;BR /&gt;  set have;&lt;BR /&gt;  count=0;&lt;BR /&gt;run;&lt;BR /&gt;data _null_;
  set have;
  call execute(cats('proc sql; update have set count=(select count(distinct case when ',name,' is null then 1 else 0 end) from ',libname,'.',memname,') where libname="',libname,'" and memname="',memname,'";'));
run;&lt;/PRE&gt;
&lt;P&gt;I have nothing to test that on.&amp;nbsp; It should generate 1 row of proc sql per row in the dataset, and those updates should insert a count into the dataset.&amp;nbsp; If count=0 all are present, if &amp;gt; 0 then null.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Dec 2018 10:05:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/checking-null-values-for-the-variables/m-p/522465#M141853</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-12-19T10:05:01Z</dc:date>
    </item>
    <item>
      <title>Re: checking null values for the variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/checking-null-values-for-the-variables/m-p/522476#M141860</link>
      <description>&lt;P&gt;please find the sample data&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data abcd;&lt;BR /&gt;input memname $ name $ libname $;&lt;BR /&gt;cards;&lt;BR /&gt;x1 v1 l1&lt;BR /&gt;x1 v2 l2&lt;BR /&gt;x2 v3 l2&lt;BR /&gt;x3 v4 l1&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;expected output:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data abcd5;&lt;BR /&gt;set abcd;&lt;BR /&gt;status2=0;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;here x1,x2,x3 are datasets corresponding to&amp;nbsp; libraries l1 and l2&amp;nbsp;&lt;/P&gt;&lt;P&gt;we want to check whether var v1 in dataset x1 is null or not&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;kindly accept apologies in case of inconvenience&lt;/P&gt;</description>
      <pubDate>Wed, 19 Dec 2018 10:55:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/checking-null-values-for-the-variables/m-p/522476#M141860</guid>
      <dc:creator>niteshbharadwaj</dc:creator>
      <dc:date>2018-12-19T10:55:57Z</dc:date>
    </item>
    <item>
      <title>Re: checking null values for the variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/checking-null-values-for-the-variables/m-p/522485#M141861</link>
      <description>&lt;P&gt;Ok, here you go.&amp;nbsp; 0 indicates no missing data items, &amp;gt;0 is count of missings:&lt;/P&gt;
&lt;PRE&gt;data abcd;
  input memname $ name $ libname $;
  status2=0;
cards;
class age work
class height work
;
run;

data class;
  set sashelp.class;
  if _n_ in (3,4) then age =.;
run;

data _null_;
  set abcd;
  call execute(cat('proc sql; 
                      update abcd 
                      set status2=(select sum(case when ',strip(name),' is null then 1 else 0 end) from ',catx('.',libname,memname),') where libname="',strip(libname),'" and memname="',strip(memname),'" and name="',strip(name),'";
                    quit;'));
run;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Dec 2018 11:20:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/checking-null-values-for-the-variables/m-p/522485#M141861</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-12-19T11:20:13Z</dc:date>
    </item>
  </channel>
</rss>

