<?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: how can i get to_char to work in proc sql without connecting to oracle? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/how-can-i-get-to-char-to-work-in-proc-sql-without-connecting-to/m-p/88753#M25300</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks SAS Bigot and BobD for saving me hours of frustration!!!!!&amp;nbsp; Wow my day just got better.&amp;nbsp; It worked.&amp;nbsp; Here's the final solution:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA PL.TREATMENT_PLANS_ADJ_RECALL;&lt;/P&gt;&lt;P&gt; SET PL.TREATMENT_PLANS_ADJ_RECALL_SETUP;&lt;/P&gt;&lt;P&gt; recalldate2 = put(intnx( 'month', datepart(recalldate), recall, 's' ), yymmn6. );&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 18 Apr 2012 22:22:27 GMT</pubDate>
    <dc:creator>teg_76</dc:creator>
    <dc:date>2012-04-18T22:22:27Z</dc:date>
    <item>
      <title>how can i get to_char to work in proc sql without connecting to oracle?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-can-i-get-to-char-to-work-in-proc-sql-without-connecting-to/m-p/88747#M25294</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm having more date issues.&amp;nbsp; I need to add a certain amount of months to a date, and the convert it to the 'YYYYMM' format.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can do this in PROC SQL if I'm pulling data from the oracle db.&amp;nbsp; Once I have a work table in SAS though I can no longer do this.&amp;nbsp; The proc sql doesn't recognize the to_char function or the add_months function. I don't know how to do the equivalent in SAS. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Basically, if I have a date&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;16SEP2012:00:00:00&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to add months to it, than convert it to a 'YYYYMM' format.&amp;nbsp; So in my code below, if RECALL=2,&lt;/P&gt;&lt;P&gt;then I would add two months to the date above, and then convert it to YYYYMM.&amp;nbsp; I'd end up with 201211 (december 2011).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's what I'm doing:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;/P&gt;&lt;P&gt;UPDATE PL.TREATMENT_PLANS_ADJ_RECALL SET RECALLDATE1=TO_CHAR(ADD_MONTHS(R.RECALLDATE, RECALL),'YYYYMM');&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I were connecting to Oracle it would work.&amp;nbsp; But I can't connect to Oracle because that's not where my table is.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for helping out this SAS date newbie!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Apr 2012 20:49:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-can-i-get-to-char-to-work-in-proc-sql-without-connecting-to/m-p/88747#M25294</guid>
      <dc:creator>teg_76</dc:creator>
      <dc:date>2012-04-18T20:49:30Z</dc:date>
    </item>
    <item>
      <title>Re: how can i get to_char to work in proc sql without connecting to oracle?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-can-i-get-to-char-to-work-in-proc-sql-without-connecting-to/m-p/88748#M25295</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;sorry 201211 would be november 2012.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Apr 2012 20:50:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-can-i-get-to-char-to-work-in-proc-sql-without-connecting-to/m-p/88748#M25295</guid>
      <dc:creator>teg_76</dc:creator>
      <dc:date>2012-04-18T20:50:27Z</dc:date>
    </item>
    <item>
      <title>Re: how can i get to_char to work in proc sql without connecting to oracle?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-can-i-get-to-char-to-work-in-proc-sql-without-connecting-to/m-p/88749#M25296</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is the equivalent SAS code:&lt;/P&gt;&lt;P&gt;recalldate1 = put( intnx( 'month', recalldate, recall, 's' ), yymmn6. );&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Apr 2012 21:09:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-can-i-get-to-char-to-work-in-proc-sql-without-connecting-to/m-p/88749#M25296</guid>
      <dc:creator>FloydNevseta</dc:creator>
      <dc:date>2012-04-18T21:09:22Z</dc:date>
    </item>
    <item>
      <title>Re: how can i get to_char to work in proc sql without connecting to oracle?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-can-i-get-to-char-to-work-in-proc-sql-without-connecting-to/m-p/88750#M25297</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi SAS_Bigot,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help.&amp;nbsp; I'm getting an error when I run this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA PL.TREATMENT_PLANS_ADJ_RECALL_2;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SET PL.TREATMENT_PLANS_ADJ_RECALL;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; recalldate2 = intnx( 'month', recalldate, recall, 's' );&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I started with the add months portion of the code.&amp;nbsp; Here's the error I get:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NOTE: Character values have been converted to numeric values at the places given by:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (Line):(Column).&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2907:47&lt;BR /&gt;NOTE: Numeric values have been converted to character values at the places given by:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (Line):(Column).&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2907:19&lt;BR /&gt;NOTE: Invalid argument to function INTNX at line 2907 column 19.&lt;BR /&gt;RECALL=6 RECALLTYPE=PX RECALLDATE=16SEP2012:00:00:00 RECALLDATE1=201209 RECALLDATE2=.&lt;BR /&gt;RECALLDATE3=201309 RECALLDATE4=201403 RECALLDATE5=201409 UNITS=3 CARIES=C0-L PERIO=P1-L AGE=3&lt;BR /&gt;_ERROR_=1 _N_=1.....................&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do you know what may be the problem?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Apr 2012 21:16:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-can-i-get-to-char-to-work-in-proc-sql-without-connecting-to/m-p/88750#M25297</guid>
      <dc:creator>teg_76</dc:creator>
      <dc:date>2012-04-18T21:16:27Z</dc:date>
    </item>
    <item>
      <title>Re: how can i get to_char to work in proc sql without connecting to oracle?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-can-i-get-to-char-to-work-in-proc-sql-without-connecting-to/m-p/88751#M25298</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Looks like recalldate is a character. Read it in with a datetime. informat and get the date part of the variable. Revised code:&lt;/P&gt;&lt;P&gt;recalldate2 = put( intnx( 'month', datepart( input( recalldate, datetime. )), recall, 's' ), yymmn6. );&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Apr 2012 21:32:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-can-i-get-to-char-to-work-in-proc-sql-without-connecting-to/m-p/88751#M25298</guid>
      <dc:creator>FloydNevseta</dc:creator>
      <dc:date>2012-04-18T21:32:17Z</dc:date>
    </item>
    <item>
      <title>Re: how can i get to_char to work in proc sql without connecting to oracle?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-can-i-get-to-char-to-work-in-proc-sql-without-connecting-to/m-p/88752#M25299</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It probably means that RECALLDATE in your SAS dataset is a character variable.&amp;nbsp; It might just look like a time-stamp, but I bet it's just a character string.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Run a PROC CONTENTS on your dataset to be sure.&amp;nbsp; If it is in fact numeric, it is a time-stamp (with a datetime format), and you will need to extract the "date" portion:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; recalldate2 = intnx( 'month', datepart(recalldate), recall, 's' );&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On the other hand, if it is a character string, re-read the first nine characters as a date:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; recalldate2 = intnx( 'month', input(substr(recalldate,1,9),date9,), recall, 's' );&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That should do it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Apr 2012 21:41:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-can-i-get-to-char-to-work-in-proc-sql-without-connecting-to/m-p/88752#M25299</guid>
      <dc:creator>BobD</dc:creator>
      <dc:date>2012-04-18T21:41:20Z</dc:date>
    </item>
    <item>
      <title>Re: how can i get to_char to work in proc sql without connecting to oracle?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-can-i-get-to-char-to-work-in-proc-sql-without-connecting-to/m-p/88753#M25300</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks SAS Bigot and BobD for saving me hours of frustration!!!!!&amp;nbsp; Wow my day just got better.&amp;nbsp; It worked.&amp;nbsp; Here's the final solution:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA PL.TREATMENT_PLANS_ADJ_RECALL;&lt;/P&gt;&lt;P&gt; SET PL.TREATMENT_PLANS_ADJ_RECALL_SETUP;&lt;/P&gt;&lt;P&gt; recalldate2 = put(intnx( 'month', datepart(recalldate), recall, 's' ), yymmn6. );&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Apr 2012 22:22:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-can-i-get-to-char-to-work-in-proc-sql-without-connecting-to/m-p/88753#M25300</guid>
      <dc:creator>teg_76</dc:creator>
      <dc:date>2012-04-18T22:22:27Z</dc:date>
    </item>
  </channel>
</rss>

