<?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: Quick datepart/date format query. in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Quick-datepart-date-format-query/m-p/666836#M19399</link>
    <description>&lt;P&gt;PS the PUT statement (used when writing to a text file) will honor the assigned format.&lt;/P&gt;</description>
    <pubDate>Fri, 03 Jul 2020 14:21:44 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2020-07-03T14:21:44Z</dc:date>
    <item>
      <title>Quick datepart/date format query.</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Quick-datepart-date-format-query/m-p/666823#M19395</link>
      <description>&lt;P&gt;Hi, This might be fairly obvious but formats have always been my downfall and I'm up against the clock or I'd try experiment. I'm doing this in an expression on an Extract Transformation in DI Studio.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;CASE WHEN DOB  ^= .
THEN input(cats(year(datepart(DOB)),month(datepart(DOB))),6.)
ELSE . END&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Gives me 20055, I'd like 200505 (dates like 200512 are already fine). The output is a straight numeric rather than a date so I didn't think it would be an issue, from a quick google I found using z as the format so tried z6. but that didn't work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any ideas? Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jul 2020 14:02:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Quick-datepart-date-format-query/m-p/666823#M19395</guid>
      <dc:creator>MRDM</dc:creator>
      <dc:date>2020-07-03T14:02:35Z</dc:date>
    </item>
    <item>
      <title>Re: Quick datepart/date format query.</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Quick-datepart-date-format-query/m-p/666826#M19396</link>
      <description>&lt;P&gt;Why do you want a mostly unusable number, instead of a date with a proper format?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;intnx('month',datepart(dob),0,'b') as newvar format=yymmn6.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;All raw date values will be aligned to the first of the month, and missing values will automatically result in missing values.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jul 2020 14:07:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Quick-datepart-date-format-query/m-p/666826#M19396</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-07-03T14:07:59Z</dc:date>
    </item>
    <item>
      <title>Re: Quick datepart/date format query.</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Quick-datepart-date-format-query/m-p/666828#M19397</link>
      <description>&lt;P&gt;It's been exported to a delimited file so won't hold the formats anyway, if it was staying in a SAS/SQL table I agree, all I need is a string with the leading zero, I have 20055 already, I just need it to be 200505. I'm not sure that code will drop into the express on an extract and would need to be user written code instead? I've not really got time to start making changes to the layout of the job and more transformations, I was hoping to just edit my current expression slightly. Missing dates are already ignored as I exclude null dates in the first part. &lt;BR /&gt;&lt;BR /&gt;Also if you think that's useless, they also want YEARDAY e.g. 200525&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":rolling_on_the_floor_laughing:"&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;I tried:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;CASE WHEN DOB  ^= .
THEN input(cats(year(datepart(DOB)),intnx('month',datepart(DOB),0,'b')),6.)
ELSE . END&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;20-10-1983 became 198386?&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jul 2020 14:15:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Quick-datepart-date-format-query/m-p/666828#M19397</guid>
      <dc:creator>MRDM</dc:creator>
      <dc:date>2020-07-03T14:15:24Z</dc:date>
    </item>
    <item>
      <title>Re: Quick datepart/date format query.</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Quick-datepart-date-format-query/m-p/666834#M19398</link>
      <description>&lt;P&gt;If you need the string, use&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;put(datepart(dob),yymmn6.)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;For the Julian date (day in a year), use the&amp;nbsp;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=leforinforref&amp;amp;docsetTarget=p0f7u4z8iuaoygn183i6q1yc49xb.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;JULIAN&lt;/A&gt;&amp;nbsp;format&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jul 2020 14:18:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Quick-datepart-date-format-query/m-p/666834#M19398</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-07-03T14:18:59Z</dc:date>
    </item>
    <item>
      <title>Re: Quick datepart/date format query.</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Quick-datepart-date-format-query/m-p/666836#M19399</link>
      <description>&lt;P&gt;PS the PUT statement (used when writing to a text file) will honor the assigned format.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jul 2020 14:21:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Quick-datepart-date-format-query/m-p/666836#M19399</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-07-03T14:21:44Z</dc:date>
    </item>
    <item>
      <title>Re: Quick datepart/date format query.</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Quick-datepart-date-format-query/m-p/666843#M19400</link>
      <description>&lt;P&gt;Thanks, I got it working with the below, I had to change it to go Numeric to Chararter as Numeric to Numeric didn't work as on MONTHDAY it was still dropping leading zeroes (not an issue with YEARMONTH).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;CASE WHEN DOB ^= . 
THEN cats(put(year(datepart(DOB)),z4.),put(month(datepart(DOB)),z2.))
ELSE "" END&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;put(datepart(dob),yymmn6.)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It got upset I think because it was going datetime to a straight numeric.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jul 2020 15:33:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Quick-datepart-date-format-query/m-p/666843#M19400</guid>
      <dc:creator>MRDM</dc:creator>
      <dc:date>2020-07-03T15:33:40Z</dc:date>
    </item>
  </channel>
</rss>

