<?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: Why wrong data picked in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Why-wrong-data-picked/m-p/850460#M336113</link>
    <description>&lt;P&gt;if I just want a subset of the dataset, what is the best way to write where&lt;/P&gt;
&lt;P&gt;if I have many variables and I only want the the following:&lt;/P&gt;
&lt;P&gt;org_code='301', account_no='1234567890123456'&lt;/P&gt;
&lt;P&gt;org_code -'251', account_no=9876543210123456'&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;can I write:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where&lt;/P&gt;
&lt;P&gt;org_code='301' and account_no='1234567890123456'&lt;/P&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;P&gt;org_code='251' and account_no='9876543210123456'&lt;/P&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;(and 20 more pairs...) ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 20 Dec 2022 09:59:26 GMT</pubDate>
    <dc:creator>HeatherNewton</dc:creator>
    <dc:date>2022-12-20T09:59:26Z</dc:date>
    <item>
      <title>Why wrong data picked</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-wrong-data-picked/m-p/850290#M336057</link>
      <description>Data application (keep=org_code application_ref_no application_no credit_card_no applicant _id);&lt;BR /&gt;Set onenov.application (encoding=any);&lt;BR /&gt;Where credit_card_no in (’0004835199841570016’, ’0004835191842460016’, &lt;BR /&gt;’0000235881284822010’, ...) /* plus another 17 similar codes*/&lt;BR /&gt;Run;&lt;BR /&gt;&lt;BR /&gt;I have the above code but strangely in the output I get credit no wrong for those not end in 0&lt;BR /&gt;Eg 0004835199841570016 becomes&lt;BR /&gt;0004835199841570010&lt;BR /&gt;&lt;BR /&gt;While those end in zero is correct&lt;BR /&gt;&lt;BR /&gt;Is the format issue?&lt;BR /&gt;</description>
      <pubDate>Mon, 19 Dec 2022 03:22:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-wrong-data-picked/m-p/850290#M336057</guid>
      <dc:creator>HeatherNewton</dc:creator>
      <dc:date>2022-12-19T03:22:59Z</dc:date>
    </item>
    <item>
      <title>Re: Why wrong data picked</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-wrong-data-picked/m-p/850292#M336058</link>
      <description>Oh I tested again with only 6 codes and it works fine&lt;BR /&gt;&lt;BR /&gt;What is the best way to do using many ORs instead in (,.,.,.,.,.)?</description>
      <pubDate>Mon, 19 Dec 2022 03:27:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-wrong-data-picked/m-p/850292#M336058</guid>
      <dc:creator>HeatherNewton</dc:creator>
      <dc:date>2022-12-19T03:27:59Z</dc:date>
    </item>
    <item>
      <title>Re: Why wrong data picked</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-wrong-data-picked/m-p/850293#M336059</link>
      <description>&lt;P&gt;SHOW the format and length associated with the variable. If you don't know how to find that then run:&lt;/P&gt;
&lt;PRE&gt;Proc contents data=onenov.application;
run;&lt;/PRE&gt;
&lt;P&gt;and share the results. There may be issues with the data.&lt;/P&gt;
&lt;P&gt;Also, any time you have questions about code behavior you should copy the code and all messages from the log and paste that into a text box. Sometimes there are messages about data conversion. Also if you have errors then a possible previous data set might be what you are looking at, not the results of this particular code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also be aware that the code you pasted shows single quotes that are curly or "smart quotes" see: (’0004835199841570016’,&lt;/P&gt;
&lt;P&gt;These cause errors. You want to make sure that the values use the simple quote ' as typed form the keyboard. They may appear as curly because of pasting into the main message window, which on this forum will reformat pasted text. It is a good idea to paste code or log entries into a text box opened on the forum with the &amp;lt;/&amp;gt; icon to prevent such.&lt;/P&gt;
&lt;P&gt;An example of what the wrong quote can do:&lt;/P&gt;
&lt;PRE&gt;333  data example;
334     set junk;
335     where credit_card_no=’0004835199841570016’;
                             -
                             22
                             76
ERROR: Syntax error while parsing WHERE clause.
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string,
              a numeric constant, a datetime constant, a missing value, (, *, +, -, :, INPUT,
              NOT, PUT, ^, ~.

ERROR 76-322: Syntax error, statement will be ignored.

336  run;
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Dec 2022 03:39:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-wrong-data-picked/m-p/850293#M336059</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-12-19T03:39:33Z</dc:date>
    </item>
    <item>
      <title>Re: Why wrong data picked</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-wrong-data-picked/m-p/850460#M336113</link>
      <description>&lt;P&gt;if I just want a subset of the dataset, what is the best way to write where&lt;/P&gt;
&lt;P&gt;if I have many variables and I only want the the following:&lt;/P&gt;
&lt;P&gt;org_code='301', account_no='1234567890123456'&lt;/P&gt;
&lt;P&gt;org_code -'251', account_no=9876543210123456'&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;can I write:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where&lt;/P&gt;
&lt;P&gt;org_code='301' and account_no='1234567890123456'&lt;/P&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;P&gt;org_code='251' and account_no='9876543210123456'&lt;/P&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;(and 20 more pairs...) ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Dec 2022 09:59:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-wrong-data-picked/m-p/850460#M336113</guid>
      <dc:creator>HeatherNewton</dc:creator>
      <dc:date>2022-12-20T09:59:26Z</dc:date>
    </item>
    <item>
      <title>Re: Why wrong data picked</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-wrong-data-picked/m-p/850464#M336114</link>
      <description>&lt;P&gt;You want to ( ) around the Pairs to make sure they are considered as such.&lt;/P&gt;
&lt;PRE&gt;where
   ( org_code='301' and account_no='1234567890123456' )
   or
   ( org_code='251' and account_no='9876543210123456')
   or
   ( &amp;lt;continue the pattern&amp;gt;)&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;If&lt;/STRONG&gt;, and this is a big if, your data is nice about combinations that occur in your data you &lt;STRONG&gt;might &lt;/STRONG&gt;be able to use shorter code such as&lt;/P&gt;
&lt;PRE&gt;where 
    org_code in ('301'  '251' &amp;lt;other codes&amp;gt;)  and account_no in ('1234567890123456'  '9876543210123456' &amp;lt;other accounts&amp;gt;)
&lt;/PRE&gt;
&lt;P&gt;This may be possible if you &lt;STRONG&gt;know&lt;/STRONG&gt;, meaning have checked, that org_code ='301' never appears with any of the account_no except '1234567890123456'. This would select org_code='301' and account_no='9876543210123456' if it occurs for example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please post code in text boxes opened using the &amp;lt;/&amp;gt; icon.&lt;/P&gt;
&lt;P&gt;That could be checked by any number of methods&lt;/P&gt;</description>
      <pubDate>Tue, 20 Dec 2022 11:37:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-wrong-data-picked/m-p/850464#M336114</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-12-20T11:37:09Z</dc:date>
    </item>
    <item>
      <title>Re: Why wrong data picked</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-wrong-data-picked/m-p/850484#M336126</link>
      <description>&lt;P&gt;You could convert the pairs into a single string so you could use IN&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where catx('|',org_code,account_no) in
 ('301|1234567890123456'
  '251|9876543210123456'
  ...
 )&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 20 Dec 2022 15:38:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-wrong-data-picked/m-p/850484#M336126</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-12-20T15:38:04Z</dc:date>
    </item>
    <item>
      <title>Re: Why wrong data picked</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-wrong-data-picked/m-p/850493#M336130</link>
      <description>&lt;P&gt;Put the codes (or code combinations) you want into their own dataset and do a join.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Dec 2022 16:17:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-wrong-data-picked/m-p/850493#M336130</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-12-20T16:17:20Z</dc:date>
    </item>
  </channel>
</rss>

