<?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: Can you use FIND function in SQL? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Can-you-use-FIND-function-in-SQL/m-p/744957#M233455</link>
    <description>&lt;P&gt;&lt;SPAN&gt;I think you have your parameters set backwards for the &lt;A href="https://support.sas.com/documentation/cdl//en/lefunctionsref/69762/HTML/default/viewer.htm#p00ab6ey29t2i8n1ihel88tqtga9.htm" target="_self"&gt;FIND() function&lt;/A&gt;.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="xis-keyword"&gt;FIND&lt;/SPAN&gt;(&lt;SPAN class="xis-userSuppliedSyntaxValue"&gt;&lt;A title="Description of syntax: string" href="https://support.sas.com/documentation/cdl//en/lefunctionsref/69762/HTML/default/p00ab6ey29t2i8n1ihel88tqtga9.htm#n14jnn741qngxrn17wb6tspj8aic" target="_blank"&gt;string&lt;/A&gt;&lt;/SPAN&gt;, &lt;SPAN class="xis-userSuppliedSyntaxValue"&gt;&lt;A title="Description of syntax: substring" href="https://support.sas.com/documentation/cdl//en/lefunctionsref/69762/HTML/default/p00ab6ey29t2i8n1ihel88tqtga9.htm#n0gy9u4zlev9kgn1r33vdz3h7of1" target="_blank"&gt;substring&lt;/A&gt;&lt;/SPAN&gt; &lt;SPAN class="xis-argOptional"&gt;&amp;lt;, &lt;SPAN class="xis-userSuppliedSyntaxValue"&gt;&lt;A title="Description of syntax: modifier" href="https://support.sas.com/documentation/cdl//en/lefunctionsref/69762/HTML/default/p00ab6ey29t2i8n1ihel88tqtga9.htm#p1sl9hzvs3hwo6n107f3y7bfumae" target="_blank"&gt;modifier(s)&lt;/A&gt;&lt;/SPAN&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="xis-argOptional"&gt;&amp;lt;, &lt;SPAN class="xis-userSuppliedSyntaxValue"&gt;&lt;A title="Description of syntax: start-position" href="https://support.sas.com/documentation/cdl//en/lefunctionsref/69762/HTML/default/p00ab6ey29t2i8n1ihel88tqtga9.htm#n15dmjyvchql8cn1w9ssx0oee2kk" target="_blank"&gt;start-position&lt;/A&gt;&lt;/SPAN&gt;&amp;gt;&lt;/SPAN&gt;)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;                                         
 create table user.step_one as                    
 select account,                                  
        cretm,                                    
        ddsusize,                                 
        dsname,                                   
        substr(dsname,1, find(dsname, '.') -1 ) as hlq
 from pdb.nfcplex_tape;  &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;That being said, &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;&amp;nbsp; is correct and SCAN() is simpler to use in this situation.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19745"&gt;@G_I_Jeff&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have a variable DSNAME with value of&amp;nbsp;NFCPSPPS.ROCK.PSXBC.F010&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to create another new variable with just the first part of the string up to the period:&lt;/P&gt;
&lt;PRE&gt;proc sql;                                         
 create table user.step_one as                    
 select account,                                  
        cretm,                                    
        ddsusize,                                 
        dsname,                                   
        substr(dsname,1,find('.',dsname)-1) as hlq
 from pdb.nfcplex_tape;                           &lt;/PRE&gt;
&lt;P&gt;The hlq variable still contains the full string of dsname.&lt;/P&gt;
&lt;P&gt;I am getting the following in my log:&lt;/P&gt;
&lt;P&gt;NOTE: INVALID ARGUMENT 3 TO FUNCTION SUBSTR. MISSING VALUES MAY BE GENERATED.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there another function, or another way to structure this in order to get what I need?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 01 Jun 2021 14:58:43 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2021-06-01T14:58:43Z</dc:date>
    <item>
      <title>Can you use FIND function in SQL?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-you-use-FIND-function-in-SQL/m-p/744945#M233450</link>
      <description>&lt;P&gt;I have a variable DSNAME with value of&amp;nbsp;NFCPSPPS.ROCK.PSXBC.F010&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to create another new variable with just the first part of the string up to the period:&lt;/P&gt;
&lt;PRE&gt;proc sql;                                         
 create table user.step_one as                    
 select account,                                  
        cretm,                                    
        ddsusize,                                 
        dsname,                                   
        substr(dsname,1,find('.',dsname)-1) as hlq
 from pdb.nfcplex_tape;                           &lt;/PRE&gt;
&lt;P&gt;The hlq variable still contains the full string of dsname.&lt;/P&gt;
&lt;P&gt;I am getting the following in my log:&lt;/P&gt;
&lt;P&gt;NOTE: INVALID ARGUMENT 3 TO FUNCTION SUBSTR. MISSING VALUES MAY BE GENERATED.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there another function, or another way to structure this in order to get what I need?&lt;/P&gt;</description>
      <pubDate>Tue, 01 Jun 2021 14:38:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-you-use-FIND-function-in-SQL/m-p/744945#M233450</guid>
      <dc:creator>G_I_Jeff</dc:creator>
      <dc:date>2021-06-01T14:38:48Z</dc:date>
    </item>
    <item>
      <title>Re: Can you use FIND function in SQL?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-you-use-FIND-function-in-SQL/m-p/744948#M233453</link>
      <description>&lt;P&gt;In your example, I'd suggest the scan function instead of find+substr&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i.e. instead of&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;substr(dsname,1,find('.',dsname)-1) as hlq&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;use&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;scan(dsname,1,'.') as hlq&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Jun 2021 14:49:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-you-use-FIND-function-in-SQL/m-p/744948#M233453</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2021-06-01T14:49:25Z</dc:date>
    </item>
    <item>
      <title>Re: Can you use FIND function in SQL?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-you-use-FIND-function-in-SQL/m-p/744956#M233454</link>
      <description>Thank you! I've never used the SCAN function before.</description>
      <pubDate>Tue, 01 Jun 2021 14:58:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-you-use-FIND-function-in-SQL/m-p/744956#M233454</guid>
      <dc:creator>G_I_Jeff</dc:creator>
      <dc:date>2021-06-01T14:58:26Z</dc:date>
    </item>
    <item>
      <title>Re: Can you use FIND function in SQL?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-you-use-FIND-function-in-SQL/m-p/744957#M233455</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I think you have your parameters set backwards for the &lt;A href="https://support.sas.com/documentation/cdl//en/lefunctionsref/69762/HTML/default/viewer.htm#p00ab6ey29t2i8n1ihel88tqtga9.htm" target="_self"&gt;FIND() function&lt;/A&gt;.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="xis-keyword"&gt;FIND&lt;/SPAN&gt;(&lt;SPAN class="xis-userSuppliedSyntaxValue"&gt;&lt;A title="Description of syntax: string" href="https://support.sas.com/documentation/cdl//en/lefunctionsref/69762/HTML/default/p00ab6ey29t2i8n1ihel88tqtga9.htm#n14jnn741qngxrn17wb6tspj8aic" target="_blank"&gt;string&lt;/A&gt;&lt;/SPAN&gt;, &lt;SPAN class="xis-userSuppliedSyntaxValue"&gt;&lt;A title="Description of syntax: substring" href="https://support.sas.com/documentation/cdl//en/lefunctionsref/69762/HTML/default/p00ab6ey29t2i8n1ihel88tqtga9.htm#n0gy9u4zlev9kgn1r33vdz3h7of1" target="_blank"&gt;substring&lt;/A&gt;&lt;/SPAN&gt; &lt;SPAN class="xis-argOptional"&gt;&amp;lt;, &lt;SPAN class="xis-userSuppliedSyntaxValue"&gt;&lt;A title="Description of syntax: modifier" href="https://support.sas.com/documentation/cdl//en/lefunctionsref/69762/HTML/default/p00ab6ey29t2i8n1ihel88tqtga9.htm#p1sl9hzvs3hwo6n107f3y7bfumae" target="_blank"&gt;modifier(s)&lt;/A&gt;&lt;/SPAN&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="xis-argOptional"&gt;&amp;lt;, &lt;SPAN class="xis-userSuppliedSyntaxValue"&gt;&lt;A title="Description of syntax: start-position" href="https://support.sas.com/documentation/cdl//en/lefunctionsref/69762/HTML/default/p00ab6ey29t2i8n1ihel88tqtga9.htm#n15dmjyvchql8cn1w9ssx0oee2kk" target="_blank"&gt;start-position&lt;/A&gt;&lt;/SPAN&gt;&amp;gt;&lt;/SPAN&gt;)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;                                         
 create table user.step_one as                    
 select account,                                  
        cretm,                                    
        ddsusize,                                 
        dsname,                                   
        substr(dsname,1, find(dsname, '.') -1 ) as hlq
 from pdb.nfcplex_tape;  &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;That being said, &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;&amp;nbsp; is correct and SCAN() is simpler to use in this situation.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19745"&gt;@G_I_Jeff&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have a variable DSNAME with value of&amp;nbsp;NFCPSPPS.ROCK.PSXBC.F010&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to create another new variable with just the first part of the string up to the period:&lt;/P&gt;
&lt;PRE&gt;proc sql;                                         
 create table user.step_one as                    
 select account,                                  
        cretm,                                    
        ddsusize,                                 
        dsname,                                   
        substr(dsname,1,find('.',dsname)-1) as hlq
 from pdb.nfcplex_tape;                           &lt;/PRE&gt;
&lt;P&gt;The hlq variable still contains the full string of dsname.&lt;/P&gt;
&lt;P&gt;I am getting the following in my log:&lt;/P&gt;
&lt;P&gt;NOTE: INVALID ARGUMENT 3 TO FUNCTION SUBSTR. MISSING VALUES MAY BE GENERATED.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there another function, or another way to structure this in order to get what I need?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Jun 2021 14:58:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-you-use-FIND-function-in-SQL/m-p/744957#M233455</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-06-01T14:58:43Z</dc:date>
    </item>
    <item>
      <title>Re: Can you use FIND function in SQL?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-you-use-FIND-function-in-SQL/m-p/744959#M233457</link>
      <description>&lt;P&gt;You have the arguments to FIND() backwards.&amp;nbsp; You are testing if DSNAME is exactly a single period.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are there values of DSNAME that do not include a period?&lt;/P&gt;
&lt;P&gt;What do you want to do in that case?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  input dsname $32. ;
  test1=substr(dsname,1,find(dsname,'.')-1);
  test2=substrn(dsname,1,find(dsname,'.')-1);
  test3=scan(dsname,1,'.');
  put (_all_) (=/);
cards;
x.y
noperiod
.
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;dsname=x.y
test1=x
test2=x
test3=x
NOTE: Invalid third argument to function SUBSTR at line 244 column 9.

dsname=noperiod
test1=noperiod
test2=
test3=noperiod
RULE:       ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
250         noperiod
dsname=noperiod test1=noperiod test2=  test3=noperiod _ERROR_=1 _N_=2
NOTE: Invalid third argument to function SUBSTR at line 244 column 9.

dsname=
test1=
test2=
test3=
251         .
dsname=  test1=  test2=  test3=  _ERROR_=1 _N_=3
NOTE: The data set WORK.TEST has 3 observations and 4 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.03 seconds
&lt;/PRE&gt;</description>
      <pubDate>Tue, 01 Jun 2021 15:01:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-you-use-FIND-function-in-SQL/m-p/744959#M233457</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-06-01T15:01:55Z</dc:date>
    </item>
  </channel>
</rss>

