<?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: check if data set has Index in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/check-if-data-set-has-Index/m-p/959582#M374376</link>
    <description>&lt;P&gt;From the docu for the&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/n0q72zlfmfjplon1p3nprf85sdin.htm" target="_self"&gt;OPEN Function&lt;/A&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;The OPEN function opens a SAS data set, DATA step, or a SAS SQL view and returns a unique numeric data set identifier, which is used in most other data set access functions. OPEN returns 0 if the data set could not be opened.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;From experience: &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The first time you use the open() function in a SAS session, the function will return a value of 1 if successful. Any time you execute the function again in the same session the return value gets incremented by 1.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Think of this value as a pointer to your opened data set that you then use in other functions.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 19 Feb 2025 10:37:20 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2025-02-19T10:37:20Z</dc:date>
    <item>
      <title>check if data set has Index</title>
      <link>https://communities.sas.com/t5/SAS-Programming/check-if-data-set-has-Index/m-p/959580#M374374</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;In order to check if a data set has index I saw the following code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let dsid=%sysfunc(open(sashelp.cars));
%put dsid=&amp;amp;dsid; /**2**/

%let indx=%sysfunc(attrn(&amp;amp;dsid,isindex));
%put indx=&amp;amp;indx; /**0**/&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;My question-&lt;/P&gt;
&lt;P&gt;&amp;amp;dsid&amp;nbsp; get value 2&amp;nbsp;&lt;/P&gt;
&lt;P&gt;what does it mean?&lt;/P&gt;
&lt;P&gt;What exactly&amp;nbsp;&amp;amp;dsid is calculating?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In code :&amp;nbsp;%let indx=%sysfunc(attrn(&amp;amp;dsid,isindex));&lt;/P&gt;
&lt;P&gt;why the argument is&amp;nbsp;&amp;amp;dsid&amp;nbsp; and not data set name (sashelp.cars)?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/kb/43/637.html" target="_blank"&gt;http://support.sas.com/kb/43/637.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2025 10:10:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/check-if-data-set-has-Index/m-p/959580#M374374</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2025-02-19T10:10:00Z</dc:date>
    </item>
    <item>
      <title>Re: check if data set has Index</title>
      <link>https://communities.sas.com/t5/SAS-Programming/check-if-data-set-has-Index/m-p/959582#M374376</link>
      <description>&lt;P&gt;From the docu for the&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/n0q72zlfmfjplon1p3nprf85sdin.htm" target="_self"&gt;OPEN Function&lt;/A&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;The OPEN function opens a SAS data set, DATA step, or a SAS SQL view and returns a unique numeric data set identifier, which is used in most other data set access functions. OPEN returns 0 if the data set could not be opened.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;From experience: &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The first time you use the open() function in a SAS session, the function will return a value of 1 if successful. Any time you execute the function again in the same session the return value gets incremented by 1.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Think of this value as a pointer to your opened data set that you then use in other functions.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2025 10:37:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/check-if-data-set-has-Index/m-p/959582#M374376</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2025-02-19T10:37:20Z</dc:date>
    </item>
    <item>
      <title>Re: check if data set has Index</title>
      <link>https://communities.sas.com/t5/SAS-Programming/check-if-data-set-has-Index/m-p/959602#M374384</link>
      <description>&lt;P&gt;The value returned by OPEN() is the something called a "file handle" in a lot of programming languages.&amp;nbsp; It is essentially a pointer to the open file that you can pass to other functions that operate on files, like the ATTRN() function (and the CLOSE() function) used in that example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You cannot just use the filename (or in this case the dataset name) because you might have the same dataset open multiple times for different purposes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Consider this simple SAS program to do a quick sort of SASHELP.CLASS by SEX.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data class ;
  set sashelp.class(where=(sex='F'))
      sashelp.class(where=(sex='M'))
  ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Feb 2025 14:11:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/check-if-data-set-has-Index/m-p/959602#M374384</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-02-19T14:11:56Z</dc:date>
    </item>
    <item>
      <title>Re: check if data set has Index</title>
      <link>https://communities.sas.com/t5/SAS-Programming/check-if-data-set-has-Index/m-p/959606#M374387</link>
      <description>&lt;P&gt;I highly recommend &lt;A title="Maxim 1" href="https://communities.sas.com/t5/SAS-Communities-Library/Maxims-of-Maximally-Efficient-SAS-Programmers/ta-p/352068/show-comments/false" target="_self"&gt;&lt;STRONG&gt;Maxim number 1&lt;/STRONG&gt;&lt;/A&gt;, it's not that hard to do.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Open() Function - Details:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/n0q72zlfmfjplon1p3nprf85sdin.htm#p0yd54ov2r2wn5n1or7xz6czlh13" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/n0q72zlfmfjplon1p3nprf85sdin.htm#p0yd54ov2r2wn5n1or7xz6czlh13&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2025 14:40:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/check-if-data-set-has-Index/m-p/959606#M374387</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2025-02-19T14:40:49Z</dc:date>
    </item>
  </channel>
</rss>

