<?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: want to keep observations if variable x equals to something in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/want-to-keep-observations-if-variable-x-equals-to-something/m-p/182878#M46567</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi ... the more the merrier ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;data sortedbase3;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;array check(2) $2 _temporary_ ("HK" "CN");&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;set sortedbase2;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;if countrycode in check;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 17 Apr 2014 15:06:38 GMT</pubDate>
    <dc:creator>MikeZdeb</dc:creator>
    <dc:date>2014-04-17T15:06:38Z</dc:date>
    <item>
      <title>want to keep observations if variable x equals to something</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/want-to-keep-observations-if-variable-x-equals-to-something/m-p/182870#M46559</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi i have a variable country code (below)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data sortedbase2; &lt;/P&gt;&lt;P&gt;set sortedbase;&lt;/P&gt;&lt;P&gt;&amp;nbsp; length countrycode $2;&lt;/P&gt;&lt;P&gt;&amp;nbsp; countrycode = substr(left(ISIN),1,2);&amp;nbsp; /* left-align ISIN and extract 2 characters starting from position 1 of ‘ISIN’ */ &lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;and I want to keep them is country code equals both HK and CN. how may i code this?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;-----------------------&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;i get an error for somereason and sas creates a variable HK and CN if ''&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*keep the ones with HK/CN;&lt;/P&gt;&lt;P&gt;data sortedbase3; &lt;/P&gt;&lt;P&gt;set sortedbase2;&lt;/P&gt;&lt;P&gt;if countrycode ne CN then delete; &lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Apr 2014 19:50:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/want-to-keep-observations-if-variable-x-equals-to-something/m-p/182870#M46559</guid>
      <dc:creator>aarony</dc:creator>
      <dc:date>2014-04-16T19:50:13Z</dc:date>
    </item>
    <item>
      <title>Re: want to keep observations if variable x equals to something</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/want-to-keep-observations-if-variable-x-equals-to-something/m-p/182871#M46560</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;you need to use " " when working with character variables:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;changing&lt;/P&gt;&lt;P&gt;if countrycode ne CN then delete;&lt;/P&gt;&lt;P&gt;to&lt;/P&gt;&lt;P&gt;if countrycode ne 'CN' then delete ;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Apr 2014 20:24:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/want-to-keep-observations-if-variable-x-equals-to-something/m-p/182871#M46560</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2014-04-16T20:24:32Z</dc:date>
    </item>
    <item>
      <title>Re: want to keep observations if variable x equals to something</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/want-to-keep-observations-if-variable-x-equals-to-something/m-p/182872#M46561</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote"&gt;&lt;SPAN style="font-size: 10pt;"&gt;and I want to keep them is country code equals both HK and CN&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;Do you perhaps mean "and I want to keep them if country code equals &lt;STRONG&gt;either&lt;/STRONG&gt; HK or CN"? Because based on what you wrote, I don't think country code can equal both HK and CN&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If so, then this should work&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data sortedbase2; &lt;/P&gt;&lt;P&gt;&amp;nbsp; set sortedbase;&lt;/P&gt;&lt;P&gt;&amp;nbsp; length countrycode $2;&lt;/P&gt;&lt;P&gt;&amp;nbsp; countrycode = substr(left(ISIN),1,2);&amp;nbsp; /* left-align ISIN and extract 2 characters starting from position 1 of ‘ISIN’ */ &lt;/P&gt;&lt;P&gt;if countrycode="HK" or countrycode="CN" then output;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Apr 2014 20:25:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/want-to-keep-observations-if-variable-x-equals-to-something/m-p/182872#M46561</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2014-04-16T20:25:59Z</dc:date>
    </item>
    <item>
      <title>Re: want to keep observations if variable x equals to something</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/want-to-keep-observations-if-variable-x-equals-to-something/m-p/182873#M46562</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;And just in case you end up wanting to use longer lists of values the IN operator is helpful:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if countrycode in ("HK", "CN") then output;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Add items as needed instead of a multitude of If this or that or somethelse or yet some other value constructs.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Apr 2014 20:34:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/want-to-keep-observations-if-variable-x-equals-to-something/m-p/182873#M46562</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2014-04-16T20:34:07Z</dc:date>
    </item>
    <item>
      <title>Re: want to keep observations if variable x equals to something</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/want-to-keep-observations-if-variable-x-equals-to-something/m-p/182874#M46563</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In addition to all the other suggestions, you don't need to actually create COUNTRYCODE.&amp;nbsp; You could use:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data sortedbase2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set sortedbase;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if left(isin) in: ('HK', 'CN') then output;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The in: comparison will use fewer characters of ISIN instead of the whole string.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Apr 2014 20:46:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/want-to-keep-observations-if-variable-x-equals-to-something/m-p/182874#M46563</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2014-04-16T20:46:41Z</dc:date>
    </item>
    <item>
      <title>Re: want to keep observations if variable x equals to something</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/want-to-keep-observations-if-variable-x-equals-to-something/m-p/182875#M46564</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here's my try with Proc SQL,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;/P&gt;&lt;P&gt;CREATE TABLE WANT AS SELECT * FROM sortedbase &lt;/P&gt;&lt;P&gt;WHERE substr(left(UPCASE(ISIN)),1,2) in ("HK","CN");&lt;/P&gt;&lt;P&gt;QUIT;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Apr 2014 04:58:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/want-to-keep-observations-if-variable-x-equals-to-something/m-p/182875#M46564</guid>
      <dc:creator>SKK</dc:creator>
      <dc:date>2014-04-17T04:58:40Z</dc:date>
    </item>
    <item>
      <title>Re: want to keep observations if variable x equals to something</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/want-to-keep-observations-if-variable-x-equals-to-something/m-p/182876#M46565</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;data sortedbase2;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;set sortedbase;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; length countrycode $2;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;if &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;substr(compress(upcase(ISIN)),1,2)&lt;/SPAN&gt; in ('HK','CN');&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; countrycode = substr(&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;compress(upcase(ISIN))&lt;/SPAN&gt;,1,2); &lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Apr 2014 06:53:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/want-to-keep-observations-if-variable-x-equals-to-something/m-p/182876#M46565</guid>
      <dc:creator>TarunKumar</dc:creator>
      <dc:date>2014-04-17T06:53:57Z</dc:date>
    </item>
    <item>
      <title>Re: want to keep observations if variable x equals to something</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/want-to-keep-observations-if-variable-x-equals-to-something/m-p/182877#M46566</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data sortedbase2; &lt;/P&gt;&lt;P&gt;&amp;nbsp; set sortedbase;&lt;/P&gt;&lt;P&gt;&amp;nbsp; where substr(left(ISIN),1,2) in ("HK","CN");&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Apr 2014 09:12:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/want-to-keep-observations-if-variable-x-equals-to-something/m-p/182877#M46566</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-04-17T09:12:23Z</dc:date>
    </item>
    <item>
      <title>Re: want to keep observations if variable x equals to something</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/want-to-keep-observations-if-variable-x-equals-to-something/m-p/182878#M46567</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi ... the more the merrier ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;data sortedbase3;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;array check(2) $2 _temporary_ ("HK" "CN");&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;set sortedbase2;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;if countrycode in check;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Apr 2014 15:06:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/want-to-keep-observations-if-variable-x-equals-to-something/m-p/182878#M46567</guid>
      <dc:creator>MikeZdeb</dc:creator>
      <dc:date>2014-04-17T15:06:38Z</dc:date>
    </item>
  </channel>
</rss>

