<?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: Reshape from wide to long in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reshape-from-wide-to-long/m-p/257734#M49523</link>
    <description>&lt;P&gt;The new date variavle doesn't have a format. Just give it a date format with the statement&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;format date yymmdd10.;&lt;/P&gt;</description>
    <pubDate>Sat, 19 Mar 2016 03:49:07 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2016-03-19T03:49:07Z</dc:date>
    <item>
      <title>Reshape from wide to long</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reshape-from-wide-to-long/m-p/257724#M49518</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;
&lt;P&gt;I have a wide dataset similar to following table and want to reshape it to long.&amp;nbsp;Variables' formats: name (character), date(date), new_id and original_id(numeric)&lt;/P&gt;
&lt;TABLE&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="43"&gt;
&lt;P&gt;name&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="44"&gt;
&lt;P&gt;Date1&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="58"&gt;
&lt;P&gt;New_id1&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="56"&gt;
&lt;P&gt;Cert_id1&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="44"&gt;
&lt;P&gt;Date2&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="58"&gt;
&lt;P&gt;New_id2&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="56"&gt;
&lt;P&gt;Cert_id2&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;The columns continue to 5.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I used the following code, however it doesn't work and I think the reason is the different formats I have.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATA long;&lt;/P&gt;
&lt;P&gt;SET wide;&lt;/P&gt;
&lt;P&gt;ARRAY adate(1:5) date1&amp;nbsp;- date5&amp;nbsp;;&lt;/P&gt;
&lt;P&gt;ARRAY anew_id(1:5) new_id1&amp;nbsp;- new_id5;&lt;/P&gt;
&lt;P&gt;ARRAY aoriginal_id(1:5) original_id1&amp;nbsp;- original_id5;&lt;/P&gt;
&lt;P&gt;DO change = 1 to 5 ;&lt;/P&gt;
&lt;P&gt;date&amp;nbsp;= adate(change);&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;new_id&lt;/SPAN&gt; =&lt;SPAN&gt;anew_id&lt;/SPAN&gt;(change);&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;original_id&lt;/SPAN&gt; =&lt;SPAN&gt;aoriginal_id&lt;/SPAN&gt;(change);&lt;/P&gt;
&lt;P&gt;OUTPUT;&lt;/P&gt;
&lt;P&gt;END;&lt;/P&gt;
&lt;P&gt;DROP&amp;nbsp;&lt;SPAN&gt;date1&amp;nbsp;- date5&lt;/SPAN&gt; &lt;SPAN&gt;new_id1&amp;nbsp;- new_id5&lt;/SPAN&gt; &lt;SPAN&gt;original_id1&amp;nbsp;- original_id5&lt;/SPAN&gt;;&lt;/P&gt;
&lt;P&gt;RUN;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I appreciate any and all suggestions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 19 Mar 2016 00:21:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reshape-from-wide-to-long/m-p/257724#M49518</guid>
      <dc:creator>m1986MM</dc:creator>
      <dc:date>2016-03-19T00:21:56Z</dc:date>
    </item>
    <item>
      <title>Re: Reshape from wide to long</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reshape-from-wide-to-long/m-p/257726#M49519</link>
      <description>&lt;P&gt;Your code appears correct to the naked eye, and your methodology is correct.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As long as type are the same for the same variable groups that shouldn't be an issue either. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please post your log and explain how it's not working.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 19 Mar 2016 01:20:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reshape-from-wide-to-long/m-p/257726#M49519</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-03-19T01:20:27Z</dc:date>
    </item>
    <item>
      <title>Re: Reshape from wide to long</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reshape-from-wide-to-long/m-p/257727#M49520</link>
      <description>&lt;P&gt;The log window looks fine.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NOTE: There were 263872 observations read from the data set&lt;SPAN&gt;WORK.WIDE&lt;/SPAN&gt;.&lt;/P&gt;
&lt;P&gt;NOTE: The data set WORK.LONG has 1319360 observations and 5 variables.&lt;/P&gt;
&lt;P&gt;NOTE: DATA statement used (Total process time): real time 0.11 seconds cpu time 0.10 seconds&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However in the newe table values are not correct. For example, the new date variable does not contain date values anymore. It's not even date format,&amp;nbsp;YYMMDD10.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the following link, example 5, explains the reshaping with a string variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.ats.ucla.edu/stat/sas/modules/widetolong_data.htm" target="_blank"&gt;http://www.ats.ucla.edu/stat/sas/modules/widetolong_data.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Because of this I&amp;nbsp;assumed that format of the date vriable is problematic. However, I don't know why it should be the case when the type of variable (date) is numeric. (its format is&amp;nbsp;YYMMDD10.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 19 Mar 2016 01:45:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reshape-from-wide-to-long/m-p/257727#M49520</guid>
      <dc:creator>m1986MM</dc:creator>
      <dc:date>2016-03-19T01:45:19Z</dc:date>
    </item>
    <item>
      <title>Re: Reshape from wide to long</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reshape-from-wide-to-long/m-p/257734#M49523</link>
      <description>&lt;P&gt;The new date variavle doesn't have a format. Just give it a date format with the statement&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;format date yymmdd10.;&lt;/P&gt;</description>
      <pubDate>Sat, 19 Mar 2016 03:49:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reshape-from-wide-to-long/m-p/257734#M49523</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-03-19T03:49:07Z</dc:date>
    </item>
    <item>
      <title>Re: Reshape from wide to long</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reshape-from-wide-to-long/m-p/257739#M49527</link>
      <description>&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Sat, 19 Mar 2016 05:49:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reshape-from-wide-to-long/m-p/257739#M49527</guid>
      <dc:creator>m1986MM</dc:creator>
      <dc:date>2016-03-19T05:49:59Z</dc:date>
    </item>
  </channel>
</rss>

