<?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: Day format? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Day-format/m-p/377461#M65463</link>
    <description>&lt;P&gt;The format width is not wide enough.&amp;nbsp; You may need 10 characters, so should specify:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;put&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Daycreated &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;sddate10.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;format&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Daycreated &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;sddate10.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;You can experiment with forcing the result to be left-hand justified, such as:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;put&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Daycreated &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;sddate10.-l&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 19 Jul 2017 16:59:56 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2017-07-19T16:59:56Z</dc:date>
    <item>
      <title>Day format?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Day-format/m-p/377441#M65459</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to assign the variable 'Daycreated' for the current day, 07/19/2017.&amp;nbsp; Also, I would like to change the format to 7/19/2017.&amp;nbsp;&amp;nbsp; I have the code below.&amp;nbsp; Somehow, error messages were shown on the log.&amp;nbsp; Please advice how to fix it.&amp;nbsp; Thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; tday = &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%sysfunc&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;(today(),yymmdd10.);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;format&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;library&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=work;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;picture&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; sddate &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;low-high = &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'%m/%d/%Y'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; (&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;datatype&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=date);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; test;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt; Daycreated =&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;'&amp;amp;tday'd&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;put&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Daycreated &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;sddate.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;format&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Daycreated &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;sddate.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;61 %let tday = %sysfunc(today(),yymmdd10.);&lt;/P&gt;
&lt;P&gt;62&lt;/P&gt;
&lt;P&gt;63 proc format library=work;&lt;/P&gt;
&lt;P&gt;64 picture sddate&lt;/P&gt;
&lt;P&gt;65 low-high = '%m/%d/%Y' (datatype=date);&lt;/P&gt;
&lt;P&gt;NOTE: Format SDDATE is already on the library WORK.FORMATS.&lt;/P&gt;
&lt;P&gt;NOTE: Format SDDATE has been output.&lt;/P&gt;
&lt;P&gt;66 run;&lt;/P&gt;
&lt;P&gt;NOTE: PROCEDURE FORMAT used (Total process time):&lt;/P&gt;
&lt;P&gt;real time 0.01 seconds&lt;/P&gt;
&lt;P&gt;cpu time 0.01 seconds&lt;/P&gt;
&lt;P&gt;　&lt;/P&gt;
&lt;P&gt;67&lt;/P&gt;
&lt;P&gt;68 data test;&lt;/P&gt;
&lt;P&gt;69 Daycreated ='&amp;amp;tday'd;&lt;/P&gt;
&lt;P&gt;--------&lt;/P&gt;
&lt;P&gt;77&lt;/P&gt;
&lt;P&gt;ERROR: Invalid date/time/datetime constant '&amp;amp;tday'd.&lt;/P&gt;
&lt;P&gt;ERROR 77-185: Invalid number conversion on '&amp;amp;tday'd.&lt;/P&gt;
&lt;P&gt;70 put Daycreated sddate.;&lt;/P&gt;
&lt;P&gt;71 format Daycreated sddate.;&lt;/P&gt;
&lt;P&gt;72 run;&lt;/P&gt;
&lt;P&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;/P&gt;
&lt;P&gt;WARNING: The data set WORK.TEST may be incomplete. When this step was stopped there were 0&lt;/P&gt;
&lt;P&gt;observations and 1 variables.&lt;/P&gt;
&lt;P&gt;WARNING: Data set WORK.TEST was not replaced because this step was stopped.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jul 2017 16:22:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Day-format/m-p/377441#M65459</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-07-19T16:22:44Z</dc:date>
    </item>
    <item>
      <title>Re: Day format?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Day-format/m-p/377442#M65460</link>
      <description>&lt;P&gt;The %LET statement should be removed entirely.&amp;nbsp; There is no need for a macro variable &amp;amp;TDAY.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The DATA step should simply assign a value to the DATA step variable:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Daycreated = today();&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jul 2017 16:27:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Day-format/m-p/377442#M65460</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-07-19T16:27:18Z</dc:date>
    </item>
    <item>
      <title>Re: Day format?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Day-format/m-p/377450#M65461</link>
      <description>&lt;P&gt;I got the result like,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Daycreated&lt;/P&gt;
&lt;P&gt;7/19/201&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Which is not I would like, How to get 7/19/2017?&amp;nbsp; Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jul 2017 16:44:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Day-format/m-p/377450#M65461</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-07-19T16:44:43Z</dc:date>
    </item>
    <item>
      <title>Re: Day format?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Day-format/m-p/377460#M65462</link>
      <description>&lt;P&gt;The shortest code to achieve what you want is:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  datecreated = today();
  format datecreated mmddyy10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;besides, use&amp;nbsp;macro variable with double quotes, not single quotes:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  Daycreated ="&amp;amp;tday"d;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;instead:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; Daycreated ='&amp;amp;tday'd;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jul 2017 16:59:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Day-format/m-p/377460#M65462</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-07-19T16:59:50Z</dc:date>
    </item>
    <item>
      <title>Re: Day format?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Day-format/m-p/377461#M65463</link>
      <description>&lt;P&gt;The format width is not wide enough.&amp;nbsp; You may need 10 characters, so should specify:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;put&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Daycreated &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;sddate10.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;format&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Daycreated &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;sddate10.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;You can experiment with forcing the result to be left-hand justified, such as:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;put&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Daycreated &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;sddate10.-l&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jul 2017 16:59:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Day-format/m-p/377461#M65463</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-07-19T16:59:56Z</dc:date>
    </item>
    <item>
      <title>Re: Day format?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Day-format/m-p/377552#M65466</link>
      <description>&lt;P style="margin: 0in 0in 8pt;"&gt;&lt;SPAN style="color: rgb(51, 51, 51); line-height: 107%; font-family: &amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 10.5pt;"&gt;So, I changed the codes based on your suggestion.&amp;nbsp; However, I found there is a problem.&amp;nbsp; I ran an extra program to change all of numeric to charterer in my actual dataset.&amp;nbsp; It turned out the 'Daycreated' became 21019.&amp;nbsp; Before running the macro, the format was perfectly fine.&amp;nbsp;&amp;nbsp; Why this happened?&amp;nbsp; How to fix it?&amp;nbsp; Basically, I don't want to change my macro program codes.&amp;nbsp; Thanks.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0in 0in 8pt;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;format&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;library&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=work;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;picture&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; sddate &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;low-high = &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'%m/%d/%Y'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; (&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;datatype&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=date);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; test;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Daycreated = today();&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;put&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Daycreated &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;sddate10.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;format&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Daycreated &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;sddate10.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; vars(dsn);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; vars;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;vars&lt;/I&gt;&lt;/STRONG&gt; (test)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jul 2017 21:12:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Day-format/m-p/377552#M65466</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-07-19T21:12:33Z</dc:date>
    </item>
    <item>
      <title>Re: Day format?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Day-format/m-p/377572#M65467</link>
      <description>&lt;P&gt;21109 is today's date on SAS's date scale.&amp;nbsp; It's the actual number returned by the TODAY() function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then your macro goes to work on all the data values, converts them ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It looks like a side effect of the macro is to remove the format that was previously applied by the FORMAT statement.&amp;nbsp; If that is what is happening here, you will need to re-issue the format in a DATA step to override the changes introduced by your macro:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;format DayCreated sddate10.;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you created a character version of _DayCreated, you might want to replace that as well since your macro uses the 8. format for all conversions.&amp;nbsp; If you wish to do that, you will need to DROP the character variable first, because its length is 8 not 10, and then add to your DATA step:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;_DayCreated = put(DayCreated, sddate10.);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jul 2017 20:13:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Day-format/m-p/377572#M65467</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-07-19T20:13:30Z</dc:date>
    </item>
    <item>
      <title>Re: Day format?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Day-format/m-p/377601#M65468</link>
      <description>&lt;P&gt;It works, you are awesome!&amp;nbsp; Thank you so much for your wonderful help, Astounding.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jul 2017 21:13:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Day-format/m-p/377601#M65468</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-07-19T21:13:53Z</dc:date>
    </item>
  </channel>
</rss>

