<?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: How do I select a range of variables using an &amp;quot;if&amp;quot; (missing data) condition? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-select-a-range-of-variables-using-an-quot-if-quot/m-p/628920#M20690</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp; Thanks so much! Works perfectly &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 02 Mar 2020 20:39:12 GMT</pubDate>
    <dc:creator>asgee</dc:creator>
    <dc:date>2020-03-02T20:39:12Z</dc:date>
    <item>
      <title>How do I select a range of variables using an "if" (missing data) condition?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-select-a-range-of-variables-using-an-quot-if-quot/m-p/628908#M20687</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 with around 98 variables. The variables are a mix of both character and numeric variables. The variables in the dataset are in a fixed order.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to select only variables #42 through #91, but keep the observations (or rows) that do not have missing data. Since variables #42 through #91 are both Character and Numeric variables, missing data has been identified as either "." or " ".&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Essentially, I still need every single variable (Variables # 1 through #98), but want to drop any observations based on missingness conditioning on variables 42-91.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried to do the code below but ended up with 0 observations (based on visual inspection alone I should have some rows left):&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*Using Variable Names;
data want;
set have;
if ("nameofvariable42" -- "nameofvariable91") = . or " " then delete;
run;


*Using Variable Numbers;
data want;
set have;
if (varnum between 42 and 91) = . or " " then delete;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried it in both methods (using the variable names &amp;amp; using the variable numbers) and ended up with the same result.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;An error in the log stated that character values were converted to numeric. Not sure if this has something to do with combining both Character and Numeric variables at the same time...&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In any case, any help would be much appreciated!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;AG&lt;/P&gt;</description>
      <pubDate>Mon, 02 Mar 2020 20:21:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-select-a-range-of-variables-using-an-quot-if-quot/m-p/628908#M20687</guid>
      <dc:creator>asgee</dc:creator>
      <dc:date>2020-03-02T20:21:56Z</dc:date>
    </item>
    <item>
      <title>Re: How do I select a range of variables using an "if" (missing data) condition?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-select-a-range-of-variables-using-an-quot-if-quot/m-p/628912#M20688</link>
      <description>&lt;P&gt;To specify a list of variables based on position use double hyphen.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;firstvar -- lastvar&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;To count the number of missing values in a list of mixed numeric and character variables use the CMISS() function.&lt;/P&gt;
&lt;P&gt;So combining these it looks like you want to do:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have (keep = firstvar -- lastvar);
  if cmiss(of firstvar -- lastvar) then delete;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 02 Mar 2020 20:27:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-select-a-range-of-variables-using-an-quot-if-quot/m-p/628912#M20688</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-03-02T20:27:05Z</dc:date>
    </item>
    <item>
      <title>Re: How do I select a range of variables using an "if" (missing data) condition?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-select-a-range-of-variables-using-an-quot-if-quot/m-p/628920#M20690</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp; Thanks so much! Works perfectly &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Mar 2020 20:39:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-select-a-range-of-variables-using-an-quot-if-quot/m-p/628920#M20690</guid>
      <dc:creator>asgee</dc:creator>
      <dc:date>2020-03-02T20:39:12Z</dc:date>
    </item>
  </channel>
</rss>

