<?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 Reshaping dataset with dates as column names to panel in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reshaping-dataset-with-dates-as-column-names-to-panel/m-p/686353#M208245</link>
    <description>&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;I have a dataset that has column names as dates and I'd like to convert it to a panel structure where those dates are all under one column called "date". I've attached what the data looks like and an desired version of the data. The actual data has a few years worth of months as column names. The 1 and 0s denote whether the car part was working or not. I don't think a simple proc transpose will solve this issue and I don't know where to start. Would appreciate your help.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 24 Sep 2020 11:57:12 GMT</pubDate>
    <dc:creator>sworobec1</dc:creator>
    <dc:date>2020-09-24T11:57:12Z</dc:date>
    <item>
      <title>Reshaping dataset with dates as column names to panel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reshaping-dataset-with-dates-as-column-names-to-panel/m-p/686353#M208245</link>
      <description>&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;I have a dataset that has column names as dates and I'd like to convert it to a panel structure where those dates are all under one column called "date". I've attached what the data looks like and an desired version of the data. The actual data has a few years worth of months as column names. The 1 and 0s denote whether the car part was working or not. I don't think a simple proc transpose will solve this issue and I don't know where to start. Would appreciate your help.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Sep 2020 11:57:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reshaping-dataset-with-dates-as-column-names-to-panel/m-p/686353#M208245</guid>
      <dc:creator>sworobec1</dc:creator>
      <dc:date>2020-09-24T11:57:12Z</dc:date>
    </item>
    <item>
      <title>Re: Reshaping dataset with dates as column names to panel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reshaping-dataset-with-dates-as-column-names-to-panel/m-p/686356#M208248</link>
      <description>&lt;P&gt;Congratulation: you have data in one of the file-formats hardly usable for anything, but data-presentation and to make the problem even more interesting the columns are named in an ill-way. The following code may need some tweaks, but it should be a useful starting point:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* automatically rename variables to be valid names */
options validvarname=v7;
/* keep-Option to prevent reading columns that have no content,
 * with _: all date-columns stay in the dataset */
proc import file="testdata.xlsx" out=work.have(keep=Car_Id Part _:) replace dbms=xlsx;
run;

/* reshaping */
proc transpose data=work.have out=work.transposed(drop=_label_ rename=(col1=Working)) name=excel_date;
   by Car_Id Part;
   var _:;
run;

/* fixing the date-variable */
data work.want;
   set work.transposed;
   
   length Date 8;
   format Date mmddyys10.;
   
   /* see https://support.sas.com/resources/papers/proceedings/proceedings/sugi29/068-29.pdf */
   Date = input(substr(excel_date, 2) - 21916, best.);
   
   drop excel_date;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 24 Sep 2020 12:48:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reshaping-dataset-with-dates-as-column-names-to-panel/m-p/686356#M208248</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2020-09-24T12:48:02Z</dc:date>
    </item>
  </channel>
</rss>

