<?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 a Column Title to Date Format in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Convert-a-Column-Title-to-Date-Format/m-p/603857#M16993</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/299461"&gt;@Hugo1989&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;As I say the raw data has the columns named as 'dd/mm/yyyy' but are formatted to display as 'mmm-yy', e.g. the current month is displayed as 'Nov-19'.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I would like to do is reformat my SAS output so that I can get it back to the format in the raw data, whether that be 'dd/mm/yyyy' or 'mmm-yy' I'm not precious about.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Don' perpetuate the layout mistakes frequently committed in Excel, which is not designed for mass data processing, but presenting small-scale data to humans.&lt;/P&gt;
&lt;P&gt;Free yourself from "spreadsheet thinking", and think SAS (which works more like a database) instead (Maxim 17).&lt;/P&gt;</description>
    <pubDate>Wed, 13 Nov 2019 13:28:25 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2019-11-13T13:28:25Z</dc:date>
    <item>
      <title>Convert a Column Title to Date Format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Convert-a-Column-Title-to-Date-Format/m-p/603830#M16985</link>
      <description>&lt;P&gt;I am currently writing a piece of code to extract specific elements of raw data into a new file. My raw data file imports from an Excel.XLSX file and has 36 columns which are titled as&amp;nbsp;dates input as "dd/mm/yyyy".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I bring this data into SAS using Proc Import it converts the format of the column titles&amp;nbsp;with the following stated within the log:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;e.g. Variable Name Change. 42370 -&amp;gt; _42370&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I now need is to&amp;nbsp;change the column titles back to a date format as they are showing in my data extract in the above format, e.g. "_ddddd". I need a piece of code to identify where columns have a&amp;nbsp;title such as the one above or similar (I have 36 columns each with a unique header according to which month it is) and then takes that and converts it to a date value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be really appreciated.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Nov 2019 12:32:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Convert-a-Column-Title-to-Date-Format/m-p/603830#M16985</guid>
      <dc:creator>Hugo1989</dc:creator>
      <dc:date>2019-11-13T12:32:29Z</dc:date>
    </item>
    <item>
      <title>Re: Convert a Column Title to Date Format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Convert-a-Column-Title-to-Date-Format/m-p/603843#M16987</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/299461"&gt;@Hugo1989&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;What I now need is to&amp;nbsp;change the column titles back to a date format&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;SAS variable names cannot be dates, so I am not sure what you are wanting as the desired end result.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Nov 2019 12:54:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Convert-a-Column-Title-to-Date-Format/m-p/603843#M16987</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-11-13T12:54:31Z</dc:date>
    </item>
    <item>
      <title>Re: Convert a Column Title to Date Format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Convert-a-Column-Title-to-Date-Format/m-p/603854#M16991</link>
      <description>&lt;P&gt;As I say the raw data has the columns named as 'dd/mm/yyyy' but are formatted to display as 'mmm-yy', e.g. the current month is displayed as 'Nov-19'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I would like to do is reformat my SAS output so that I can get it back to the format in the raw data, whether that be 'dd/mm/yyyy' or 'mmm-yy' I'm not precious about.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Nov 2019 13:23:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Convert-a-Column-Title-to-Date-Format/m-p/603854#M16991</guid>
      <dc:creator>Hugo1989</dc:creator>
      <dc:date>2019-11-13T13:23:14Z</dc:date>
    </item>
    <item>
      <title>Re: Convert a Column Title to Date Format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Convert-a-Column-Title-to-Date-Format/m-p/603855#M16992</link>
      <description>&lt;P&gt;First, you need to correct your data layout and transpose from wide to long (Maxims 33 &amp;amp; 19).&lt;/P&gt;
&lt;P&gt;Then you extract substr(_name_,2) and convert it to a number. You add '30dec1899'd, attach a date format, and you're done.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Nov 2019 13:23:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Convert-a-Column-Title-to-Date-Format/m-p/603855#M16992</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-11-13T13:23:39Z</dc:date>
    </item>
    <item>
      <title>Re: Convert a Column Title to Date Format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Convert-a-Column-Title-to-Date-Format/m-p/603857#M16993</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/299461"&gt;@Hugo1989&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;As I say the raw data has the columns named as 'dd/mm/yyyy' but are formatted to display as 'mmm-yy', e.g. the current month is displayed as 'Nov-19'.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I would like to do is reformat my SAS output so that I can get it back to the format in the raw data, whether that be 'dd/mm/yyyy' or 'mmm-yy' I'm not precious about.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Don' perpetuate the layout mistakes frequently committed in Excel, which is not designed for mass data processing, but presenting small-scale data to humans.&lt;/P&gt;
&lt;P&gt;Free yourself from "spreadsheet thinking", and think SAS (which works more like a database) instead (Maxim 17).&lt;/P&gt;</description>
      <pubDate>Wed, 13 Nov 2019 13:28:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Convert-a-Column-Title-to-Date-Format/m-p/603857#M16993</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-11-13T13:28:25Z</dc:date>
    </item>
    <item>
      <title>Re: Convert a Column Title to Date Format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Convert-a-Column-Title-to-Date-Format/m-p/603874#M16994</link>
      <description>&lt;P&gt;You probably want to make the output as a REPORT instead of a dataset.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So let's mimic your input gibberish.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
  input id :$10. _42370 _42401;
cards;
NJ 345  456
NY 1234 789
;
proc print data=have; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;Obs    id    _42370    _42401

 1     NJ      345       456
 2     NY     1234       789&lt;/PRE&gt;
&lt;P&gt;First convert it to a TALL structure where the column header is now in a variable that you can manipulate.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=have out=tall ;
  by id ;
  var _: ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now you can convert those goofy numbers into actual DATE values.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data tall2;
  set tall ;
  date = input(substr(_name_,2),32.)+'30DEC1899'd;
  format date date9. ;
run;
proc print data= tall2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;Obs    id    _NAME_    COL1         date

 1     NJ    _42370     345    01JAN2016
 2     NJ    _42401     456    01FEB2016
 3     NY    _42370    1234    01JAN2016
 4     NY    _42401     789    01FEB2016&lt;/PRE&gt;
&lt;P&gt;Now you can make a REPORT that uses the value of the date as the column header.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report data=tall2 ;
  column id col1,date ;
  define id / group ;
  define date / across order=internal format=monyy7. ' ';
  define col1 / sum ' ';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;  id            JAN2016    FEB2016
  NJ                345        456
  NY               1234        789&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Nov 2019 14:52:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Convert-a-Column-Title-to-Date-Format/m-p/603874#M16994</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-11-13T14:52:49Z</dc:date>
    </item>
    <item>
      <title>Re: Convert a Column Title to Date Format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Convert-a-Column-Title-to-Date-Format/m-p/604043#M17018</link>
      <description>&lt;P&gt;Really helpful Tom, thanks very much!!&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2019 08:59:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Convert-a-Column-Title-to-Date-Format/m-p/604043#M17018</guid>
      <dc:creator>Hugo1989</dc:creator>
      <dc:date>2019-11-14T08:59:17Z</dc:date>
    </item>
    <item>
      <title>Re: Convert a Column Title to Date Format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Convert-a-Column-Title-to-Date-Format/m-p/604083#M17020</link>
      <description>&lt;P&gt;Note how the transposition I was talking about (and which is the most important step in &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;'s solution) immediately opens you up to make use of the powers of SAS.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2019 12:50:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Convert-a-Column-Title-to-Date-Format/m-p/604083#M17020</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-11-14T12:50:33Z</dc:date>
    </item>
  </channel>
</rss>

