<?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: Select all with condition in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Select-all-with-condition/m-p/857983#M37874</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I think &amp;nbsp;SUBSTR(MFCUST14,-3,3) is empty&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;try this&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;PROC SQL; CREATE TABLE V1 AS SELECT *&amp;nbsp; FROM ACTUAL WHERE SUBSTR(MFCUST14,length(MFCUST14)-2,3) IN ('HCI','CIW','HFI','FIW');quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 09 Feb 2023 10:44:07 GMT</pubDate>
    <dc:creator>SAS76FR</dc:creator>
    <dc:date>2023-02-09T10:44:07Z</dc:date>
    <item>
      <title>Select all with condition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Select-all-with-condition/m-p/857973#M37870</link>
      <description>PROC SQL; CREATE TABLE V1 AS SELECT * FROM ACTUAL WHERE SUBSTR(MFCUST14,-3,3) IN ('HCI','CIW','HFI','FIW);&lt;BR /&gt;&lt;BR /&gt;Why there's empty output eventhough MFCUST14=M9005FIW is in the table?</description>
      <pubDate>Thu, 09 Feb 2023 10:01:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Select-all-with-condition/m-p/857973#M37870</guid>
      <dc:creator>tinton</dc:creator>
      <dc:date>2023-02-09T10:01:27Z</dc:date>
    </item>
    <item>
      <title>Re: Select all with condition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Select-all-with-condition/m-p/857977#M37871</link>
      <description>It's okay, I've figure it out. Just use Select * from actual where mfcust14 like '%HFI';</description>
      <pubDate>Thu, 09 Feb 2023 10:22:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Select-all-with-condition/m-p/857977#M37871</guid>
      <dc:creator>tinton</dc:creator>
      <dc:date>2023-02-09T10:22:56Z</dc:date>
    </item>
    <item>
      <title>Re: Select all with condition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Select-all-with-condition/m-p/857983#M37874</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I think &amp;nbsp;SUBSTR(MFCUST14,-3,3) is empty&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;try this&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;PROC SQL; CREATE TABLE V1 AS SELECT *&amp;nbsp; FROM ACTUAL WHERE SUBSTR(MFCUST14,length(MFCUST14)-2,3) IN ('HCI','CIW','HFI','FIW');quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2023 10:44:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Select-all-with-condition/m-p/857983#M37874</guid>
      <dc:creator>SAS76FR</dc:creator>
      <dc:date>2023-02-09T10:44:07Z</dc:date>
    </item>
    <item>
      <title>Re: Select all with condition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Select-all-with-condition/m-p/857984#M37875</link>
      <description>&lt;P&gt;I believe you want to read last three characters from the variable&amp;nbsp;&lt;SPAN&gt;MFCUST14 and compare it with&amp;nbsp;('HCI','CIW','HFI','FIW). If this is true then you need to calculate length of the string first and then subtract -2 from it. The strip function used here to remove all leading or trailing blanks from a variable&amp;nbsp;MFCUST14.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The below code will give you better understanding:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data _null_;
	MFCUST14='M9005FIW';
	sub_str=SUBSTR(strip(MFCUST14), length(MFCUST14)-2, 3);
	put MFCUST14=;
	put sub_str=;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Log:&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;DIV class=""&gt;&lt;FONT size="2"&gt;69 data _null_;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;FONT size="2"&gt;70 MFCUST14='M9005FIW';&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;FONT size="2"&gt;71 sub_str=SUBSTR(strip(MFCUST14), length(MFCUST14)-2, 3);&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;FONT size="2"&gt;72 put MFCUST14=;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;FONT size="2"&gt;73 put sub_str=;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;FONT size="2"&gt;74 run;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;FONT size="2"&gt;MFCUST14=M9005FIW&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;FONT size="2"&gt;sub_str=FIW&lt;/FONT&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If this is your objective then you need to adjust your proc sql code accordingly. But I'd suggest using data step instead of a proc sql.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data actual;
	MFCUST14='M9005FIW';
	output;
	MFCUST14='M9005FI3';
	output;
	MFCUST14='M9CIW';
	output;
	MFCUST14='M9005XYZ';
	output;
run;

data V1;
	set ACTUAL;

	if SUBSTR(MFCUST14, length(MFCUST14)-2, 3) IN ('HCI', 'CIW', 'HFI', 'FIW') then
		output;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2023 10:44:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Select-all-with-condition/m-p/857984#M37875</guid>
      <dc:creator>MayurJadhav</dc:creator>
      <dc:date>2023-02-09T10:44:25Z</dc:date>
    </item>
  </channel>
</rss>

