<?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: Convert Date to Character in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Convert-Date-to-Character/m-p/349605#M81121</link>
    <description>&lt;P&gt;That's absolutely not how you code in SAS.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Start from the beginning, what do you have, what do you want and what have you tried.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your current code mixes SAS SQL, DATA step code and a bunch of other stuff that I'm not even sure what you're doing.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Include your code that you currently have that works that you're trying to add on to or explain where you're starting from.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm guessing you're new to SAS so you may also want to consider the training courses which are free.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, converting a date to a character variable is rarely a good idea in SAS. Usually only recommended when you're trying to export data.&lt;/P&gt;</description>
    <pubDate>Wed, 12 Apr 2017 20:33:02 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-04-12T20:33:02Z</dc:date>
    <item>
      <title>Convert Date to Character</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-Date-to-Character/m-p/349562#M81091</link>
      <description>&lt;P&gt;PROC SQL&lt;/P&gt;&lt;P&gt;SELECT&lt;BR /&gt;PUT(YR_2016,DATE9.)AS YR_2016;&lt;BR /&gt;PUT (YR_2015, DATE9.) AS YR_2015;&lt;BR /&gt;PUT (MONTH_START_DATE,DATE9.) AS MONTH_START_DATE;&lt;/P&gt;&lt;P&gt;DATA CALENDAR;&lt;BR /&gt;INFILE "//sas_env/empl/scm/Mahek/hw_query_calendar.csv" DELIMITER = ',' MISSOVER DSD LRECL=32767 FIRSTOBS=2 ;&lt;BR /&gt;INFORMAT CALENDAR_DATE MMDDYY10.;&lt;BR /&gt;INFORMAT FISCAL_YEAR 6.;&lt;BR /&gt;INFORMAT FISCAL_MONTH 6.;&lt;BR /&gt;INFORMAT FYQUARTER $6.;&lt;BR /&gt;INFORMAT MONTH_START_DATE MMDDYY10.;&lt;BR /&gt;FORMAT CALENDAR_DATE MMDDYY10.;&lt;BR /&gt;FORMAT FISCAL_YEAR 6.;&lt;BR /&gt;FORMAT FISCAL_MONTH 6.;&lt;BR /&gt;FORMAT FYQUARTER $6.;&lt;BR /&gt;FORMAT MONTH_START_DATE MMDDYY10.;&lt;BR /&gt;INPUT CALENDAR_DATE FISCAL_YEAR FISCAL_MONTH FYQUARTER $ MONTH_START_DATE ;&lt;BR /&gt;IF CALENDAR_DATE = TODAY();&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;DATA CALENDAR2;&lt;BR /&gt;SET CALENDAR;&lt;BR /&gt;FORMAT QUERY_QTR $10.;&lt;BR /&gt;QUERY_QTR = "FY"||COMPRESS(SUBSTR(FYQUARTER,3,2))||' '||"Q"||COMPRESS(SUBSTR(FYQUARTER,6,1));&lt;BR /&gt;FORMAT YR_2016 MMDDYY10.;&lt;BR /&gt;PUT(YR_2016,DATE9.)AS YR_2016;&lt;BR /&gt;YR_2016 = MONTH_START_DATE - 364;&lt;BR /&gt;PUT (MONTH_START_DATE,DATE9.) AS MONTH_START_DATE;&lt;BR /&gt;FORMAT YR_2015 MMDDYY10.;&lt;BR /&gt;PUT (YR_2015, DATE9.) AS YR_2015;&lt;BR /&gt;YR_2015 = YR_2016 - 364;&lt;BR /&gt;RUN;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Apr 2017 19:18:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-Date-to-Character/m-p/349562#M81091</guid>
      <dc:creator>lbridges225</dc:creator>
      <dc:date>2017-04-12T19:18:46Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Date to Character</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-Date-to-Character/m-p/349565#M81093</link>
      <description>&lt;P&gt;What is the question?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your code is incorrect in many respsects just from a quick scan and I don't know where to start, so your question&amp;nbsp;can help clarify the issue.Remember we can't run your code and I really don't want to read every line to highlight all your errors.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;At an absolute minimum include your log and clarify your question in detail please.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When debugging fix the first error, re-run and then fix the next first error etc until everything works as expected.&lt;/P&gt;
&lt;P&gt;Also, check every step and make sure it works before you move on, by every step I mean any PROC/DATA steps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://stackoverflow.com/help/how-to-ask" target="_blank"&gt;https://stackoverflow.com/help/how-to-ask&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Apr 2017 19:25:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-Date-to-Character/m-p/349565#M81093</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-04-12T19:25:11Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Date to Character</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-Date-to-Character/m-p/349575#M81101</link>
      <description>&lt;P&gt;I want to convert YR_2015, YR_2016 and MONTH_START_DATE from date to character. &amp;nbsp;I am trying to use a PUT but not having any luck. &amp;nbsp;Someone said I need a new PROC SQL statement...but not sure how to begin...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA CALENDAR2;&lt;BR /&gt;SET CALENDAR;&lt;BR /&gt;FORMAT QUERY_QTR $10.;&lt;BR /&gt;QUERY_QTR = "FY"||COMPRESS(SUBSTR(FYQUARTER,3,2))||' '||"Q"||COMPRESS(SUBSTR(FYQUARTER,6,1));&lt;BR /&gt;FORMAT YR_2016 MMDDYY10.;&lt;BR /&gt;PUT(YR_2016,DATE9.)AS YR_2016;&lt;BR /&gt;YR_2016 = MONTH_START_DATE - 364;&lt;BR /&gt;PUT (MONTH_START_DATE,DATE9.) AS MONTH_START_DATE;&lt;BR /&gt;FORMAT YR_2015 MMDDYY10.;&lt;BR /&gt;PUT (YR_2015, DATE9.) AS YR_2015;&lt;BR /&gt;YR_2015 = YR_2016 - 364;&lt;BR /&gt;RUN;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Apr 2017 19:42:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-Date-to-Character/m-p/349575#M81101</guid>
      <dc:creator>lbridges225</dc:creator>
      <dc:date>2017-04-12T19:42:49Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Date to Character</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-Date-to-Character/m-p/349603#M81119</link>
      <description>&lt;P&gt;Are your existing YR_2015, YR_2016 and MONTH_START_DATE&amp;nbsp;SAS date values?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The general run when applying a function or calculations to variables &lt;STRONG&gt;in SQL&lt;/STRONG&gt; to create a new variable is&lt;/P&gt;
&lt;P&gt;(calculation code) as resultingvariable name. If you use the SAME variable name the the variable TYPE will stay the same. You cannot change a variable type from numeric to character (or vice versa) in SAS. EVER.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;put(yr_2015,date9) as Char_Yr_2015&lt;/P&gt;
&lt;P&gt;would create a new text variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;IN a data step the equivalent is&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; Char_Yr_2015 = put(yr_2015,Date9.); &amp;lt;= Note that DATA step does &lt;STRONG&gt;not use AS&lt;/STRONG&gt; to indicate the target variable. It is the name of the variable to the left of the =.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;though I wonder why not using the Format date9. with the existing variable is not sufficient.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Apr 2017 20:31:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-Date-to-Character/m-p/349603#M81119</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-04-12T20:31:05Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Date to Character</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-Date-to-Character/m-p/349605#M81121</link>
      <description>&lt;P&gt;That's absolutely not how you code in SAS.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Start from the beginning, what do you have, what do you want and what have you tried.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your current code mixes SAS SQL, DATA step code and a bunch of other stuff that I'm not even sure what you're doing.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Include your code that you currently have that works that you're trying to add on to or explain where you're starting from.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm guessing you're new to SAS so you may also want to consider the training courses which are free.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, converting a date to a character variable is rarely a good idea in SAS. Usually only recommended when you're trying to export data.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Apr 2017 20:33:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-Date-to-Character/m-p/349605#M81121</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-04-12T20:33:02Z</dc:date>
    </item>
  </channel>
</rss>

