<?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: Keep only certain rows in a variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Keep-only-certain-rows-in-a-variable/m-p/340914#M272716</link>
    <description>&lt;P&gt;Do you use any documentation of sas ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can compare any character variable - either to another variable like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;if var1 = var2 &amp;nbsp; | &amp;nbsp; &amp;nbsp;if var1 &amp;gt; var2 &amp;nbsp; etc.&lt;/P&gt;
&lt;P&gt;or you can compare it to a literal, exact equation like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; if var = "any string" &amp;nbsp; &amp;nbsp; | &amp;nbsp;if var = 'other string' &amp;nbsp; etc.&lt;/P&gt;
&lt;P&gt;or you can compare to an expression as I have done:&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;where upcase(substr(MEASURE ID,1,6)) = "PSI_90";&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;the difference between IF and WHERE is the timing of compare.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;WHERE is executed towards the input buffer while the IF is executed after bringing the record to work area.&lt;/P&gt;
&lt;P&gt;I have used two functtions:&lt;/P&gt;
&lt;P&gt;1) the inner SUBSTRING with 3 arguments: variable name (string to check), start position, end position&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2) the outer UPCASE in order to be sure that I comapr to upper case as in "PSI..." literal.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With this information I expect that you can solve yourself your last question - just change the literal you want to compare to.&lt;/P&gt;</description>
    <pubDate>Tue, 14 Mar 2017 18:58:50 GMT</pubDate>
    <dc:creator>Shmuel</dc:creator>
    <dc:date>2017-03-14T18:58:50Z</dc:date>
    <item>
      <title>Keep only certain rows in a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-only-certain-rows-in-a-variable/m-p/340664#M272709</link>
      <description>&lt;P&gt;I have a dataset of several hospitals. There are several variables. One of the variables is MEASURE ID. I want to keep only those rows that have MEASURE ID= PSI_90 and drop the rest of the rows. How can I do that? I am a beginner so please excuse me if the question is too basic. Thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SU&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2017 05:55:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-only-certain-rows-in-a-variable/m-p/340664#M272709</guid>
      <dc:creator>soumya12</dc:creator>
      <dc:date>2017-03-14T05:55:48Z</dc:date>
    </item>
    <item>
      <title>Re: Keep only certain rows in a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-only-certain-rows-in-a-variable/m-p/340665#M272710</link>
      <description>&lt;P&gt;Use next code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
        where &lt;SPAN&gt;MEASURE ID= PSI_90;&lt;BR /&gt;run;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Mar 2017 05:59:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-only-certain-rows-in-a-variable/m-p/340665#M272710</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-03-14T05:59:03Z</dc:date>
    </item>
    <item>
      <title>Re: Keep only certain rows in a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-only-certain-rows-in-a-variable/m-p/340863#M272711</link>
      <description>&lt;P&gt;Hi Schmuel:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your reply. I tried that but all I get is a new dataset which is empty. Has 0 observations. Could you please advise. My original dataset looks like the one in the screen shot attached.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SU&lt;/P&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/13560i8F4E12E8DA4F458F/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="VirtualBox_windows10_14_03_2017_00_31_51.png" title="VirtualBox_windows10_14_03_2017_00_31_51.png" /&gt;</description>
      <pubDate>Tue, 14 Mar 2017 17:16:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-only-certain-rows-in-a-variable/m-p/340863#M272711</guid>
      <dc:creator>soumya12</dc:creator>
      <dc:date>2017-03-14T17:16:41Z</dc:date>
    </item>
    <item>
      <title>Re: Keep only certain rows in a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-only-certain-rows-in-a-variable/m-p/340878#M272712</link>
      <description>&lt;P&gt;Since you did not provide any data in the original post &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/88384"&gt;@Shmuel&lt;/a&gt;&amp;nbsp;had to guess that you meant when one variable was equal to another not a text value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data want;
    set have;
    where MEASURE ID= "PSI_90";
run;&lt;/PRE&gt;
&lt;P&gt;might work, but your posted picture shows a &lt;STRONG&gt;value&lt;/STRONG&gt; of PSI_90_SAFETY. If that is the value you are looking for then that is the string to place between the quotes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Spelling counts in programming.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2017 17:46:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-only-certain-rows-in-a-variable/m-p/340878#M272712</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-03-14T17:46:50Z</dc:date>
    </item>
    <item>
      <title>Re: Keep only certain rows in a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-only-certain-rows-in-a-variable/m-p/340880#M272713</link>
      <description>&lt;P&gt;I see your issue:&lt;/P&gt;
&lt;P&gt;You are not looking for&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;MEASURE &lt;SPAN class="token keyword"&gt;ID&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; PSI_90&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;as there is no variabled named PSI_90.&lt;/P&gt;
&lt;P&gt;NOR for&lt;/P&gt;
&lt;PRE&gt;MEASURE ID= "PSI_90";&lt;/PRE&gt;
&lt;P&gt;as yvalues are in a format of: &amp;nbsp;PSI_nn_xxxxx&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So the right code should be:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data want;
    set have;
    where upcase(substr(MEASURE ID,1,6)) = "PSI_90";
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2017 17:55:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-only-certain-rows-in-a-variable/m-p/340880#M272713</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-03-14T17:55:34Z</dc:date>
    </item>
    <item>
      <title>Re: Keep only certain rows in a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-only-certain-rows-in-a-variable/m-p/340908#M272714</link>
      <description>&lt;P&gt;I am looking for scores for only those rows in which Measure ID= PSI_90_SAFETY. So, I want the first two variables&amp;nbsp;in my resulting dataset to look like: ProviderID, PSI_90_Score. The second variable&amp;nbsp;PSI_90_Score is renamed from the variable Score. And I am looking for scores only for PSI_90_SAFETY and drop everything else. Please help!!&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2017 18:41:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-only-certain-rows-in-a-variable/m-p/340908#M272714</guid>
      <dc:creator>soumya12</dc:creator>
      <dc:date>2017-03-14T18:41:13Z</dc:date>
    </item>
    <item>
      <title>Re: Keep only certain rows in a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-only-certain-rows-in-a-variable/m-p/340912#M272715</link>
      <description>&lt;P&gt;Since your example showed PSI_90 as being part of the value PSI_90 safety, I'd think you're looking for something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data want;
  set have (where=(measure_id contains 'PSI_90'));
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2017 18:50:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-only-certain-rows-in-a-variable/m-p/340912#M272715</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-03-14T18:50:27Z</dc:date>
    </item>
    <item>
      <title>Re: Keep only certain rows in a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-only-certain-rows-in-a-variable/m-p/340914#M272716</link>
      <description>&lt;P&gt;Do you use any documentation of sas ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can compare any character variable - either to another variable like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;if var1 = var2 &amp;nbsp; | &amp;nbsp; &amp;nbsp;if var1 &amp;gt; var2 &amp;nbsp; etc.&lt;/P&gt;
&lt;P&gt;or you can compare it to a literal, exact equation like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; if var = "any string" &amp;nbsp; &amp;nbsp; | &amp;nbsp;if var = 'other string' &amp;nbsp; etc.&lt;/P&gt;
&lt;P&gt;or you can compare to an expression as I have done:&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;where upcase(substr(MEASURE ID,1,6)) = "PSI_90";&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;the difference between IF and WHERE is the timing of compare.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;WHERE is executed towards the input buffer while the IF is executed after bringing the record to work area.&lt;/P&gt;
&lt;P&gt;I have used two functtions:&lt;/P&gt;
&lt;P&gt;1) the inner SUBSTRING with 3 arguments: variable name (string to check), start position, end position&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2) the outer UPCASE in order to be sure that I comapr to upper case as in "PSI..." literal.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With this information I expect that you can solve yourself your last question - just change the literal you want to compare to.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2017 18:58:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-only-certain-rows-in-a-variable/m-p/340914#M272716</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-03-14T18:58:50Z</dc:date>
    </item>
  </channel>
</rss>

