<?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: Need to extract data which has &amp;quot;*&amp;quot; as value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Need-to-extract-data-which-has-quot-quot-as-value/m-p/397725#M96149</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/62004"&gt;@vraj1&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Something like below should do.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  infile datalines truncover;
  input var $20.;
datalines;
8.3
22 *
6.7 H *
120 H *
34 L *

;
run;

/* option 1 */
data want1;
  set have;
  if prxmatch('/(h|l)\s*\*$/oi',strip(var));
run;

/* option 2 */
data want2(drop=_:);
  set have;
  _var=compress(var);
  if upcase(substrn(_var,lengthn(_var)-1)) in ('L*','H*');
run;

/* option 3 */
data want3;
  set have;
  if strip(scan(var,-1,'lh','i')) ='*';
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Preferred option: Option 3&lt;/P&gt;</description>
    <pubDate>Thu, 21 Sep 2017 10:35:35 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2017-09-21T10:35:35Z</dc:date>
    <item>
      <title>Need to extract data which has "*" as value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-extract-data-which-has-quot-quot-as-value/m-p/397706#M96138</link>
      <description>&lt;P&gt;I have a variable which has caharacter values and i want to extract values which ends with *.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;var&lt;/P&gt;
&lt;P&gt;5.6 H *&lt;/P&gt;
&lt;P&gt;4.3&lt;/P&gt;
&lt;P&gt;2.6&lt;/P&gt;
&lt;P&gt;9.6 L *&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can i do that?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 08:18:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-extract-data-which-has-quot-quot-as-value/m-p/397706#M96138</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2017-09-21T08:18:58Z</dc:date>
    </item>
    <item>
      <title>Re: Need to extract data which has "*" as value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-extract-data-which-has-quot-quot-as-value/m-p/397712#M96139</link>
      <description>&lt;P&gt;Try this....&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WANT;
  set HAVE;
  where indexc(var_char,"*");
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 08:42:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-extract-data-which-has-quot-quot-as-value/m-p/397712#M96139</guid>
      <dc:creator>ShiroAmada</dc:creator>
      <dc:date>2017-09-21T08:42:42Z</dc:date>
    </item>
    <item>
      <title>Re: Need to extract data which has "*" as value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-extract-data-which-has-quot-quot-as-value/m-p/397714#M96141</link>
      <description>&lt;P&gt;Thanks a lot can i include multiple conditions in it like&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;  &lt;SPAN class="token statement"&gt;where&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;indexc&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;var_char&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"H*" "L*"&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;so that i can extract values which has "H*" and "L*"?&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 09:15:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-extract-data-which-has-quot-quot-as-value/m-p/397714#M96141</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2017-09-21T09:15:06Z</dc:date>
    </item>
    <item>
      <title>Re: Need to extract data which has "*" as value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-extract-data-which-has-quot-quot-as-value/m-p/397715#M96142</link>
      <description>&lt;P&gt;What's next after you have flagged records with "*"? &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;INDEXC - i think this is limited to just a character you can google it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try this....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  where indexc(var,"*");
  chars=catx(" ",scan(var,-2" "),scan(var,-1," "));
run;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 09:44:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-extract-data-which-has-quot-quot-as-value/m-p/397715#M96142</guid>
      <dc:creator>ShiroAmada</dc:creator>
      <dc:date>2017-09-21T09:44:17Z</dc:date>
    </item>
    <item>
      <title>Re: Need to extract data which has "*" as value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-extract-data-which-has-quot-quot-as-value/m-p/397716#M96143</link>
      <description>&lt;P&gt;I need to have values only which has either "L*" or "H*" values and the rest be deleted.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 09:42:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-extract-data-which-has-quot-quot-as-value/m-p/397716#M96143</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2017-09-21T09:42:53Z</dc:date>
    </item>
    <item>
      <title>Re: Need to extract data which has "*" as value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-extract-data-which-has-quot-quot-as-value/m-p/397717#M96144</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  where indexc(var,"*");
  chars=catx(" ",scan(var,-2" "),scan(var,-1," "));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Sep 2017 09:47:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-extract-data-which-has-quot-quot-as-value/m-p/397717#M96144</guid>
      <dc:creator>ShiroAmada</dc:creator>
      <dc:date>2017-09-21T09:47:47Z</dc:date>
    </item>
    <item>
      <title>Re: Need to extract data which has "*" as value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-extract-data-which-has-quot-quot-as-value/m-p/397719#M96145</link>
      <description>&lt;P&gt;It doesnt work unfortunately&lt;/P&gt;
&lt;P&gt;var&lt;/P&gt;
&lt;P&gt;8.3&lt;/P&gt;
&lt;P&gt;22 *&lt;/P&gt;
&lt;P&gt;6.7 H *&lt;/P&gt;
&lt;P&gt;120 H *&lt;/P&gt;
&lt;P&gt;34 L *&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need the below&lt;/P&gt;
&lt;P&gt;var&lt;/P&gt;
&lt;P&gt;6.7 H *&lt;/P&gt;
&lt;P&gt;120 H *&lt;/P&gt;
&lt;P&gt;34 L *&lt;/P&gt;
&lt;P&gt;there is space between number and H or L and *&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 09:51:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-extract-data-which-has-quot-quot-as-value/m-p/397719#M96145</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2017-09-21T09:51:59Z</dc:date>
    </item>
    <item>
      <title>Re: Need to extract data which has "*" as value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-extract-data-which-has-quot-quot-as-value/m-p/397720#M96146</link>
      <description>&lt;P&gt;Here is a better version.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try this....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WANT;
  set HAVE;
where indexc(var,"*");

char_used=ifc(find(var,"H *",1),"H *","L *");
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Since when a record has an "*" the values are either "H *" or "L *".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you just want those records containing "H *" or "L *" then remove the assignment statement for char_used.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 09:56:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-extract-data-which-has-quot-quot-as-value/m-p/397720#M96146</guid>
      <dc:creator>ShiroAmada</dc:creator>
      <dc:date>2017-09-21T09:56:11Z</dc:date>
    </item>
    <item>
      <title>Re: Need to extract data which has "*" as value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-extract-data-which-has-quot-quot-as-value/m-p/397721#M96147</link>
      <description>&lt;P&gt;Thanks, but this just gives&amp;nbsp;H * or L *&lt;/P&gt;
&lt;P&gt;I need the entire values like if it is 345 H * i need the entire&amp;nbsp;&lt;SPAN&gt;345 H *&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 09:56:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-extract-data-which-has-quot-quot-as-value/m-p/397721#M96147</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2017-09-21T09:56:10Z</dc:date>
    </item>
    <item>
      <title>Re: Need to extract data which has "*" as value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-extract-data-which-has-quot-quot-as-value/m-p/397724#M96148</link>
      <description>&lt;P&gt;where index(var, 'H *') or index(var, 'L *');&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The initial focus on the * led in the direction of using INDEXC. &amp;nbsp;Switch to INDEX.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 10:27:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-extract-data-which-has-quot-quot-as-value/m-p/397724#M96148</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-09-21T10:27:29Z</dc:date>
    </item>
    <item>
      <title>Re: Need to extract data which has "*" as value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-extract-data-which-has-quot-quot-as-value/m-p/397725#M96149</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/62004"&gt;@vraj1&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Something like below should do.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  infile datalines truncover;
  input var $20.;
datalines;
8.3
22 *
6.7 H *
120 H *
34 L *

;
run;

/* option 1 */
data want1;
  set have;
  if prxmatch('/(h|l)\s*\*$/oi',strip(var));
run;

/* option 2 */
data want2(drop=_:);
  set have;
  _var=compress(var);
  if upcase(substrn(_var,lengthn(_var)-1)) in ('L*','H*');
run;

/* option 3 */
data want3;
  set have;
  if strip(scan(var,-1,'lh','i')) ='*';
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Preferred option: Option 3&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 10:35:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-extract-data-which-has-quot-quot-as-value/m-p/397725#M96149</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-09-21T10:35:35Z</dc:date>
    </item>
  </channel>
</rss>

