<?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: Deleting observations based on the first letter of the observation. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Deleting-observations-based-on-the-first-letter-of-the/m-p/596010#M171554</link>
    <description>&lt;P&gt;So I have tried this, but it still produces a data set with all states not just the states that begin with the letter M. I think I need a piece of code like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;if state= "M--------" then keep;&lt;/P&gt;&lt;P&gt;else delete;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But i'm not sure how to go about doing that...&lt;/P&gt;</description>
    <pubDate>Sun, 13 Oct 2019 00:21:31 GMT</pubDate>
    <dc:creator>valarievil</dc:creator>
    <dc:date>2019-10-13T00:21:31Z</dc:date>
    <item>
      <title>Deleting observations based on the first letter of the observation.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-observations-based-on-the-first-letter-of-the/m-p/596004#M171551</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset with 6 variables. one of those variables is state (california, idaho, nevada, ect.) How would I go about excluding states that don't begin with the letter M?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 12 Oct 2019 23:22:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-observations-based-on-the-first-letter-of-the/m-p/596004#M171551</guid>
      <dc:creator>valarievil</dc:creator>
      <dc:date>2019-10-12T23:22:48Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting observations based on the first letter of the observation.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-observations-based-on-the-first-letter-of-the/m-p/596007#M171553</link>
      <description>&lt;P&gt;Editted note:&amp;nbsp; this particular example assume STATE is all capital letters.&amp;nbsp; If not, then use&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; UPCASE(STATE)&lt;/P&gt;
&lt;P&gt;in every place I have used&lt;/P&gt;
&lt;P&gt;&amp;nbsp; STATE&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the old days you could&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  where state&amp;lt;'M' or state &amp;gt;='N';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But a while ago SAS introduced the "=:" relation, which allows you to:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  where not (state=:'M');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The '"=:" relation, exclusively used for character values, tells SAS to take the two values in question, and see if the shorter one exactly matches the leading characters of the longer one.&amp;nbsp; By "shorter" and "longer", I don't mean storage length.&amp;nbsp; Instead I mean the number of characters in the value excluding the trailing blanks.&lt;/P&gt;</description>
      <pubDate>Sat, 12 Oct 2019 23:32:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-observations-based-on-the-first-letter-of-the/m-p/596007#M171553</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2019-10-12T23:32:15Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting observations based on the first letter of the observation.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-observations-based-on-the-first-letter-of-the/m-p/596010#M171554</link>
      <description>&lt;P&gt;So I have tried this, but it still produces a data set with all states not just the states that begin with the letter M. I think I need a piece of code like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;if state= "M--------" then keep;&lt;/P&gt;&lt;P&gt;else delete;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But i'm not sure how to go about doing that...&lt;/P&gt;</description>
      <pubDate>Sun, 13 Oct 2019 00:21:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-observations-based-on-the-first-letter-of-the/m-p/596010#M171554</guid>
      <dc:creator>valarievil</dc:creator>
      <dc:date>2019-10-13T00:21:31Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting observations based on the first letter of the observation.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-observations-based-on-the-first-letter-of-the/m-p/596011#M171555</link>
      <description>&lt;P&gt;Alternatively: ne is mnemonic for not equal, and eq for equal&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where state ne: 'M';&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 13 Oct 2019 00:27:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-observations-based-on-the-first-letter-of-the/m-p/596011#M171555</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2019-10-13T00:27:26Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting observations based on the first letter of the observation.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-observations-based-on-the-first-letter-of-the/m-p/596012#M171556</link>
      <description>&lt;P&gt;data want;&lt;BR /&gt;set have;&lt;BR /&gt;if state=:'M' then output;&lt;BR /&gt;if state=:'N' then output;&lt;BR /&gt;else delete;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My goal was to delete all states that did not begin with the letter M or N. This worked for me. thanks all!&lt;/P&gt;</description>
      <pubDate>Sun, 13 Oct 2019 00:34:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-observations-based-on-the-first-letter-of-the/m-p/596012#M171556</guid>
      <dc:creator>valarievil</dc:creator>
      <dc:date>2019-10-13T00:34:36Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting observations based on the first letter of the observation.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-observations-based-on-the-first-letter-of-the/m-p/596013#M171557</link>
      <description>&lt;P&gt;With the IF statement this is one solution. You should read the documentation on the different types of expressions you can use in an IF statement. Trying to guess how statements work is only going to get you frustrated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This link is a good one to explore: &lt;A href="https://documentation.sas.com/?docsetId=lrcon&amp;amp;docsetTarget=lrconwhatsnew94.htm&amp;amp;docsetVersion=9.4&amp;amp;loca" target="_blank"&gt;https://documentation.sas.com/?docsetId=lrcon&amp;amp;docsetTarget=lrconwhatsnew94.htm&amp;amp;docsetVersion=9.4&amp;amp;loca&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if state =: "M" then output;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 13 Oct 2019 00:42:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-observations-based-on-the-first-letter-of-the/m-p/596013#M171557</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2019-10-13T00:42:43Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting observations based on the first letter of the observation.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-observations-based-on-the-first-letter-of-the/m-p/596018#M171559</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;:&lt;/P&gt;
&lt;P&gt;Mark, instead of upcasing the whole thing, can do:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where state in: ("m","M") ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;which in my WHERE tests against &lt;EM&gt;sashelp.zipcode(keep=statecode)&lt;/EM&gt; times 1000 works more than twice as fast compared to:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where upcase (state) =: "M" ; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Looks like UPCASE (and also $UPCASE1. - have tested that, too) is much more expensive than testing for another value via IN.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Paul D.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 13 Oct 2019 01:34:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-observations-based-on-the-first-letter-of-the/m-p/596018#M171559</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2019-10-13T01:34:54Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting observations based on the first letter of the observation.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-observations-based-on-the-first-letter-of-the/m-p/596024#M171563</link>
      <description>&lt;P&gt;Nice.&lt;/P&gt;</description>
      <pubDate>Sun, 13 Oct 2019 02:58:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-observations-based-on-the-first-letter-of-the/m-p/596024#M171563</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2019-10-13T02:58:40Z</dc:date>
    </item>
  </channel>
</rss>

