<?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: In( range) in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/In-range/m-p/46526#M12402</link>
    <description>Yes, I'd thought of that, but many of the categories will be lists of non-sequential numbers so I really want to use in( ).&lt;BR /&gt;
&lt;BR /&gt;
Thanks though.&lt;BR /&gt;
&lt;BR /&gt;
For now I've written lists out longhand, but I'll need to do this a lot so ranges would be better.&lt;BR /&gt;
&lt;BR /&gt;
I could macroise (if that's a word) the query so define the query at the top (different for each category) and then just call the query macro further down. Bit messy though. Using simple ranges in in( ) seems like it would be very useful and people I've been asking here all want me to report back if i can get it working. &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;</description>
    <pubDate>Tue, 16 Sep 2008 12:48:42 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2008-09-16T12:48:42Z</dc:date>
    <item>
      <title>In( range)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/In-range/m-p/46524#M12400</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
I'd like to be able to able to specify a range in an in( ) statement in a where clause.&lt;BR /&gt;
&lt;BR /&gt;
%if &amp;amp;category. eq 'all' %then %let spids=1:30;&lt;BR /&gt;
proc freq data=mydata;&lt;BR /&gt;
tables scorecard;&lt;BR /&gt;
where spid1 in(&amp;amp;spids.);&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
It doesn't like the : to specify a range.&lt;BR /&gt;
There may be many categories with a variety of ranges so I dont want to 1,2,3 all of them.&lt;BR /&gt;
&lt;BR /&gt;
Any suggestions?&lt;BR /&gt;
&lt;BR /&gt;
I've not been doing SAS for long but i'm keen to learn so please don't worry about teaching me to suck eggs. &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;</description>
      <pubDate>Tue, 16 Sep 2008 10:33:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/In-range/m-p/46524#M12400</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-09-16T10:33:00Z</dc:date>
    </item>
    <item>
      <title>Re: In( range)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/In-range/m-p/46525#M12401</link>
      <description>... %let spids=1 and 30;&lt;BR /&gt;
..&lt;BR /&gt;
where spid1 between &amp;amp;SPIDS.;&lt;BR /&gt;
...&lt;BR /&gt;
&lt;BR /&gt;
/Linus</description>
      <pubDate>Tue, 16 Sep 2008 10:48:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/In-range/m-p/46525#M12401</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2008-09-16T10:48:20Z</dc:date>
    </item>
    <item>
      <title>Re: In( range)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/In-range/m-p/46526#M12402</link>
      <description>Yes, I'd thought of that, but many of the categories will be lists of non-sequential numbers so I really want to use in( ).&lt;BR /&gt;
&lt;BR /&gt;
Thanks though.&lt;BR /&gt;
&lt;BR /&gt;
For now I've written lists out longhand, but I'll need to do this a lot so ranges would be better.&lt;BR /&gt;
&lt;BR /&gt;
I could macroise (if that's a word) the query so define the query at the top (different for each category) and then just call the query macro further down. Bit messy though. Using simple ranges in in( ) seems like it would be very useful and people I've been asking here all want me to report back if i can get it working. &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;</description>
      <pubDate>Tue, 16 Sep 2008 12:48:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/In-range/m-p/46526#M12402</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-09-16T12:48:42Z</dc:date>
    </item>
    <item>
      <title>Re: In( range)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/In-range/m-p/46527#M12403</link>
      <description>Consider the use of a numeric SAS format, which can be setup to handle ranges and explicit values.  The SAS FORMAT procedure can be used to generate/maintain your values, either as instream code using a VALUE statement to build the format, or by using an external data file with the ranges / values, and then use a DATA step to read up the external file, build a SAS file suitable for use with PROC FORMAT and CNTLIN= to generate the format.  Then you would use a PUT function in your WHERE statement rather than specifying a range.&lt;BR /&gt;
&lt;BR /&gt;
Have a look at the SAS support website resources &lt;A href="http://support.sas.com/" target="_blank"&gt;http://support.sas.com/&lt;/A&gt; for references to PROC FORMAT, and my recommended approach which is to use CNTLIN=.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Tue, 16 Sep 2008 19:20:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/In-range/m-p/46527#M12403</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2008-09-16T19:20:03Z</dc:date>
    </item>
    <item>
      <title>Re: In( range)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/In-range/m-p/46528#M12404</link>
      <description>Just remember thai if you data is indexed on your "spid" is indexed or your data reside in an external RDBMS, you don't want any function calls in you where-clause. Use Scott's suggestion with %let, %sysfunc and putn function prior to your query (like in your initial example).&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
Linus</description>
      <pubDate>Wed, 17 Sep 2008 06:48:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/In-range/m-p/46528#M12404</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2008-09-17T06:48:18Z</dc:date>
    </item>
  </channel>
</rss>

