<?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: ERROR: Function SUBSTR requires a character expression as argument 1. when linking by DOB in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/ERROR-Function-SUBSTR-requires-a-character-expression-as/m-p/668146#M79094</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/205036"&gt;@DanielQuay&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks for the pointer everyone.&amp;nbsp; I don't have it kicked entirely yet but these have been really good insights.&amp;nbsp;&amp;nbsp;&lt;BR /&gt;I also learned that the codebook I was using mislabeled the HAVE2 data as numeric, it's character that's an insight I could've used before posting.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You may want to consider running Proc Contents on your Have2 data set and compare everything to your code book. One error such as this for a common variable concept like date of birth makes me cringe.&lt;/P&gt;
&lt;P&gt;And dates should be numeric but as SAS date values with an appropriate date format assigned, not character.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Character dates seldom sort properly and basically never graph properly plus use for things like computing age at a given date or intervals between values is obnoxious at best and generally means creating a date value as an intermediate step.&lt;/P&gt;</description>
    <pubDate>Thu, 09 Jul 2020 19:13:03 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2020-07-09T19:13:03Z</dc:date>
    <item>
      <title>ERROR: Function SUBSTR requires a character expression as argument 1. when linking by DOB</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/ERROR-Function-SUBSTR-requires-a-character-expression-as/m-p/668110#M79089</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So the problem I'm having is I get this error&amp;nbsp;ERROR: Function SUBSTR requires a character expression as argument 1.&lt;/P&gt;&lt;P&gt;I'm trying to link two datasets based upon the Name and Date of Birth.&lt;/P&gt;&lt;P&gt;However, whenever I try to link based on the date of birth I get this ERROR.&lt;BR /&gt;&lt;BR /&gt;Here is how I'm creating the DOB variable for HAVE1:&amp;nbsp;dob_c = input(cat(de_bmo, de_bday, de_byr), mmddyy8.);&amp;nbsp;&lt;/P&gt;&lt;P&gt;The variable I am linking to is a numeric variable for date of birth in HAVE2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table WANT as&lt;BR /&gt;select a.*, cat(compress(medrecno),compress(uniqpati),dis_date) as unique_id_ev, b.yod_cert&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;from HAVE2 as a&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;left join HAVE1 as b on compress(a.patiname) = cat(compress(b.de_lname),',',compress(b.de_fname))&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;and a.bth_date = substr(b.dob_c,1,2)||substr(b.dob_c,4,2)||substr(b.dob_c,7,4)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;where b.de_fname is not null and cat(compress(medrecno),compress(uniqpati),dis_date) not in (select unique_id_ev from out_2017)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; and dispos ne '20' and input(a.dis_date,mmddyy8.) &amp;lt; b.deathdate;&lt;BR /&gt;quit;&lt;BR /&gt;&lt;BR /&gt;I'm really not good with PROC SQL coding so any help you can give me here would be appreciated.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jul 2020 17:30:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/ERROR-Function-SUBSTR-requires-a-character-expression-as/m-p/668110#M79089</guid>
      <dc:creator>DanielQuay</dc:creator>
      <dc:date>2020-07-09T17:30:07Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Function SUBSTR requires a character expression as argument 1. when linking by DOB</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/ERROR-Function-SUBSTR-requires-a-character-expression-as/m-p/668116#M79090</link>
      <description>&lt;P&gt;Since you create dob_c with a date informat, it is a SAS date variable (numeric, counts days from 1960-01-01). If bth_date is also a SAS date value, you can compare them directly. If it is not a SAS date value but represents a date, then convert it first.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jul 2020 17:41:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/ERROR-Function-SUBSTR-requires-a-character-expression-as/m-p/668116#M79090</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-07-09T17:41:08Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Function SUBSTR requires a character expression as argument 1. when linking by DOB</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/ERROR-Function-SUBSTR-requires-a-character-expression-as/m-p/668118#M79091</link>
      <description>&lt;P&gt;This is not an SQL problem. This is a SUBSTR problem. You need to have a character expression as argument 1. You get this error message because in one (or more) of your calls to SUBSTR, you have a NUMERIC variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, you will find your coding is much easier if you don't try to pull apart dates via constructs such as&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;substr(b.dob_c,1,2)||substr(b.dob_c,4,2)||substr(b.dob_c,7,4)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Treat dates as numeric dates, and all of these problems go away.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jul 2020 17:42:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/ERROR-Function-SUBSTR-requires-a-character-expression-as/m-p/668118#M79091</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-07-09T17:42:30Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Function SUBSTR requires a character expression as argument 1. when linking by DOB</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/ERROR-Function-SUBSTR-requires-a-character-expression-as/m-p/668125#M79092</link>
      <description>Use the MDY() function to create your date instead of the INPUT().&lt;BR /&gt;Did you double check the results of CAT()? It often introduces spaces so usually you should use CATT() instead.</description>
      <pubDate>Thu, 09 Jul 2020 17:58:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/ERROR-Function-SUBSTR-requires-a-character-expression-as/m-p/668125#M79092</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-07-09T17:58:30Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Function SUBSTR requires a character expression as argument 1. when linking by DOB</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/ERROR-Function-SUBSTR-requires-a-character-expression-as/m-p/668127#M79093</link>
      <description>&lt;P&gt;Thanks for the pointer everyone.&amp;nbsp; I don't have it kicked entirely yet but these have been really good insights.&amp;nbsp;&amp;nbsp;&lt;BR /&gt;I also learned that the codebook I was using mislabeled the HAVE2 data as numeric, it's character that's an insight I could've used before posting.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jul 2020 18:05:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/ERROR-Function-SUBSTR-requires-a-character-expression-as/m-p/668127#M79093</guid>
      <dc:creator>DanielQuay</dc:creator>
      <dc:date>2020-07-09T18:05:47Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Function SUBSTR requires a character expression as argument 1. when linking by DOB</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/ERROR-Function-SUBSTR-requires-a-character-expression-as/m-p/668146#M79094</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/205036"&gt;@DanielQuay&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks for the pointer everyone.&amp;nbsp; I don't have it kicked entirely yet but these have been really good insights.&amp;nbsp;&amp;nbsp;&lt;BR /&gt;I also learned that the codebook I was using mislabeled the HAVE2 data as numeric, it's character that's an insight I could've used before posting.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You may want to consider running Proc Contents on your Have2 data set and compare everything to your code book. One error such as this for a common variable concept like date of birth makes me cringe.&lt;/P&gt;
&lt;P&gt;And dates should be numeric but as SAS date values with an appropriate date format assigned, not character.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Character dates seldom sort properly and basically never graph properly plus use for things like computing age at a given date or intervals between values is obnoxious at best and generally means creating a date value as an intermediate step.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jul 2020 19:13:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/ERROR-Function-SUBSTR-requires-a-character-expression-as/m-p/668146#M79094</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-07-09T19:13:03Z</dc:date>
    </item>
  </channel>
</rss>

