<?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: Character Date Conversion in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Character-Date-Conversion/m-p/810290#M319537</link>
    <description>&lt;P&gt;Hi, This worked for me.&amp;nbsp; Thanks so much!&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 28 Apr 2022 00:33:43 GMT</pubDate>
    <dc:creator>runi_r</dc:creator>
    <dc:date>2022-04-28T00:33:43Z</dc:date>
    <item>
      <title>Character Date Conversion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-Date-Conversion/m-p/810237#M319509</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to convert a character date time stamp with time zone information into a date time variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My date variable is stored in this format, "YYYY-MM-DD"T"HH24:MI:SS.ff3"Z.""&amp;nbsp; Here is an example value from my data set:&amp;nbsp;2022-03-09T14:00:00Z.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ideally, I would like to change values to&amp;nbsp;mmddyy10 or any date format.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is one proc sql method I tried:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;proc sql;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; select to_char(to_timestamp_tz(2022-03-09T14:00:00Z, 'YYYY-MM-DD"T"HH24:MI:SS.ff3"Z"'), 'DD-MON- YY') FMT from rpt&lt;BR /&gt;&amp;nbsp; &amp;nbsp;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my error:&amp;nbsp;&lt;/P&gt;&lt;P&gt;29 select to_char(to_timestamp_tz(2022-03-09T14:00:00Z, 'YYYY-MM-DD"T"HH24:MI:SS.ff3"Z"'), 'DD-MON-YY') FMT&lt;BR /&gt;___&lt;BR /&gt;22&lt;BR /&gt;76&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, ), *, **, +, ',', -, /, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;=, ?,&lt;BR /&gt;AND, BETWEEN, CONTAINS, EQ, EQT, GE, GET, GT, GTT, IN, IS, LE, LET, LIKE, LT, LTT, NE, NET, NOT, NOTIN,&lt;BR /&gt;OR, ^, ^=, |, ||, ~, ~=.&lt;/P&gt;&lt;P&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is greatly appreciated!&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2022 17:19:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-Date-Conversion/m-p/810237#M319509</guid>
      <dc:creator>runi_r</dc:creator>
      <dc:date>2022-04-27T17:19:10Z</dc:date>
    </item>
    <item>
      <title>Re: Character Date Conversion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-Date-Conversion/m-p/810245#M319511</link>
      <description>&lt;P&gt;Please, whenever you get an error in the LOG, show us the &lt;FONT color="#FF0000"&gt;ENTIRE&lt;/FONT&gt; log for this PROC or DATA step. Do not pick and choose parts to show us and leave other parts of the log out. Please copy the log as test and paste it into the window that appears when you click on the &amp;lt;/&amp;gt; icon.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Insert Log Icon in SAS Communities.png" style="width: 859px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66171iFEC370B1DBF07B28/image-size/large?v=v2&amp;amp;px=999" role="button" title="Insert Log Icon in SAS Communities.png" alt="Insert Log Icon in SAS Communities.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, please tell us what PROC CONTENTS says about this variable in your data set. Does PROC CONTENTS say it is numeric or text?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Lastly, to_timestamp_tz is not a SAS function.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2022 17:38:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-Date-Conversion/m-p/810245#M319511</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-04-27T17:38:48Z</dc:date>
    </item>
    <item>
      <title>Re: Character Date Conversion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-Date-Conversion/m-p/810249#M319512</link>
      <description>Hi,&lt;BR /&gt;Please try this.&lt;BR /&gt;&lt;BR /&gt;data rpt;&lt;BR /&gt;input timestp $20.;&lt;BR /&gt;datalines;&lt;BR /&gt;2022-03-09T14:00:00&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;select input(timestp,anydtdtm21.) as FMT format = datetime18. from rpt;&lt;BR /&gt;quit;</description>
      <pubDate>Wed, 27 Apr 2022 17:51:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-Date-Conversion/m-p/810249#M319512</guid>
      <dc:creator>Santt0sh</dc:creator>
      <dc:date>2022-04-27T17:51:18Z</dc:date>
    </item>
    <item>
      <title>Re: Character Date Conversion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-Date-Conversion/m-p/810290#M319537</link>
      <description>&lt;P&gt;Hi, This worked for me.&amp;nbsp; Thanks so much!&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 00:33:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-Date-Conversion/m-p/810290#M319537</guid>
      <dc:creator>runi_r</dc:creator>
      <dc:date>2022-04-28T00:33:43Z</dc:date>
    </item>
    <item>
      <title>Re: Character Date Conversion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-Date-Conversion/m-p/810291#M319538</link>
      <description>&lt;PRE&gt;1                                                    The SAS System

1          ;*';*";*/;quit;run;
2          OPTIONS PAGENO=MIN;
3          %LET _CLIENTTASKLABEL='report2.sas';
4          %LET _CLIENTPROCESSFLOWNAME='Process Flow';
5          %LET _CLIENTPROJECTPATH='.egp';
6          %LET _CLIENTPROJECTPATHHOST='';
7          %LET _CLIENTPROJECTNAME='.egp';
8          %LET _SASPROGRAMFILE='report2.sas';
9          %LET _SASPROGRAMFILEHOST='';
10         
11         ODS _ALL_ CLOSE;
12         OPTIONS DEV=SVG;
13         GOPTIONS XPIXELS=0 YPIXELS=0;
14         %macro HTML5AccessibleGraphSupported;
15             %if %_SAS_VERCOMP(9, 4, 4) &amp;gt;= 0 %then ACCESSIBLE_GRAPH;
16         %mend;
17         FILENAME EGHTML TEMP;
18         ODS HTML5(ID=EGHTML) FILE=EGHTML
19             OPTIONS(BITMAP_MODE='INLINE')
20             %HTML5AccessibleGraphSupported
21             ENCODING='utf-8'
22             STYLE=HtmlBlue
23             NOGTITLE
24             NOGFOOTNOTE
25             GPATH=&amp;amp;sasworklocation
26         ;
NOTE: Writing HTML5(EGHTML) Body file: EGHTML
27         


28            proc sql;
29               select to_char(to_timestamp_tz(2022-03-09T14:00:00Z, 'YYYY-MM-DD"T"HH24:MI:SS.ff3"Z"'), 'DD-MON- YY')
                                                          ___
                                                          22
                                                          76
29       ! FMT from rpt;
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, ), *, **, +, ',', -, /, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;=, ?, 
              AND, BETWEEN, CONTAINS, EQ, EQT, GE, GET, GT, GTT, IN, IS, LE, LET, LIKE, LT, LTT, NE, NET, NOT, NOTIN, 
              OR, ^, ^=, |, ||, ~, ~=.  

ERROR 76-322: Syntax error, statement will be ignored.

NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
30            quit;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      
31         
32         %LET _CLIENTTASKLABEL=;
33         %LET _CLIENTPROCESSFLOWNAME=;
34         %LET _CLIENTPROJECTPATH=;
35         %LET _CLIENTPROJECTPATHHOST=;
36         %LET _CLIENTPROJECTNAME=;
37         %LET _SASPROGRAMFILE=;
38         %LET _SASPROGRAMFILEHOST=;
39         
2                                                    The SAS System

40         ;*';*";*/;quit;run;
41         ODS _ALL_ CLOSE;
42         
43         
44         QUIT; RUN;
45         &lt;/PRE&gt;&lt;P&gt;This is stored as a character variable in existing dataset.&amp;nbsp; I also stated this in title of my question.&amp;nbsp; More specifically format is $Char24.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 00:42:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-Date-Conversion/m-p/810291#M319538</guid>
      <dc:creator>runi_r</dc:creator>
      <dc:date>2022-04-28T00:42:25Z</dc:date>
    </item>
  </channel>
</rss>

