<?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 How to handle different date formats when I transpose a table? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-handle-different-date-formats-when-I-transpose-a-table/m-p/528456#M144234</link>
    <description>&lt;P&gt;I want to create a table that displays different examples of date formats.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data Date_formats;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;var1 = 20165;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;var2 = 20165;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;var3 = 20165;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;format var1 date7. var2 date9. var3 date11.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;run;&lt;BR /&gt;&lt;BR /&gt;The output is a table that looks like this:&lt;BR /&gt;&lt;BR /&gt;var1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;var3&lt;BR /&gt;18MAR15&amp;nbsp; 18MAR2015 18-MAR-2015&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I want to transpose this table to look like the following:&lt;BR /&gt;var1 18MAR15&lt;BR /&gt;var2 18MAR2015&lt;BR /&gt;var3 18-MAR-2015&lt;BR /&gt;&lt;BR /&gt;But instead when I use Proc Transpose, it just turns all of the dates back to the SAS date format (20165).&lt;BR /&gt;&lt;BR /&gt;I tried converting them all to characters using var1=put(20165,date7.), but then proc transpose wont't display them at all.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;P&gt;-Barry&lt;/P&gt;</description>
    <pubDate>Fri, 18 Jan 2019 21:33:47 GMT</pubDate>
    <dc:creator>BarryP</dc:creator>
    <dc:date>2019-01-18T21:33:47Z</dc:date>
    <item>
      <title>How to handle different date formats when I transpose a table?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-handle-different-date-formats-when-I-transpose-a-table/m-p/528456#M144234</link>
      <description>&lt;P&gt;I want to create a table that displays different examples of date formats.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data Date_formats;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;var1 = 20165;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;var2 = 20165;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;var3 = 20165;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;format var1 date7. var2 date9. var3 date11.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;run;&lt;BR /&gt;&lt;BR /&gt;The output is a table that looks like this:&lt;BR /&gt;&lt;BR /&gt;var1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;var3&lt;BR /&gt;18MAR15&amp;nbsp; 18MAR2015 18-MAR-2015&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I want to transpose this table to look like the following:&lt;BR /&gt;var1 18MAR15&lt;BR /&gt;var2 18MAR2015&lt;BR /&gt;var3 18-MAR-2015&lt;BR /&gt;&lt;BR /&gt;But instead when I use Proc Transpose, it just turns all of the dates back to the SAS date format (20165).&lt;BR /&gt;&lt;BR /&gt;I tried converting them all to characters using var1=put(20165,date7.), but then proc transpose wont't display them at all.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;P&gt;-Barry&lt;/P&gt;</description>
      <pubDate>Fri, 18 Jan 2019 21:33:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-handle-different-date-formats-when-I-transpose-a-table/m-p/528456#M144234</guid>
      <dc:creator>BarryP</dc:creator>
      <dc:date>2019-01-18T21:33:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to handle different date formats when I transpose a table?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-handle-different-date-formats-when-I-transpose-a-table/m-p/528466#M144238</link>
      <description>&lt;P&gt;A single variable (column) can only have one format. If you want a data set to get something that looks like that you would have to create new character variables from&amp;nbsp; var1 - var3 using the PUT function with the desired format and then transpose the text variables .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We would have to see your data and complete code to determine why the character version you tried didn't produce desired results.&lt;/P&gt;
&lt;PRE&gt;var1=put(20165,date7.), &lt;/PRE&gt;
&lt;P&gt;would not create a character variable because you have already defined var1 as numeric. You would need to do something like.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;var1_c = put(var1,date7.) ;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do you expect to use that transposed data set? Perhaps you are transposing when it is not needed.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Jan 2019 22:01:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-handle-different-date-formats-when-I-transpose-a-table/m-p/528466#M144238</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-01-18T22:01:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to handle different date formats when I transpose a table?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-handle-different-date-formats-when-I-transpose-a-table/m-p/528467#M144239</link>
      <description>&lt;P&gt;Hi:&lt;BR /&gt; In your transposed data, var1, var2 and var3 will each have the value of 20165 (march 18, 2015). However, in a data set, you can only have 1 format associated with a single column so inside the data, the variable value. In a report, on the other hand, you could display each row's value with a different format. Other folks can answer the transpose question. If you have 2 variables in the transposed data called TYPE and VAL, then this would work in PROC REPORT. As shown here:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="call_define_format_same_val.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/26370i71339F1574246D9E/image-size/large?v=v2&amp;amp;px=999" role="button" title="call_define_format_same_val.png" alt="call_define_format_same_val.png" /&gt;&lt;/span&gt;&lt;BR /&gt;Cynthia&lt;/P&gt;</description>
      <pubDate>Fri, 18 Jan 2019 22:10:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-handle-different-date-formats-when-I-transpose-a-table/m-p/528467#M144239</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2019-01-18T22:10:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to handle different date formats when I transpose a table?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-handle-different-date-formats-when-I-transpose-a-table/m-p/528494#M144250</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;I tried converting them all to characters using var1=put(20165,date7.), but then proc transpose wont't display them at all.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;PROC TRANSPOSE can work with character variables, but you need list them in the VAR statement.&amp;nbsp; &amp;nbsp;If you leave off the VAR statement then PROC TRANSPOSE will just transpose the numeric variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 19 Jan 2019 03:02:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-handle-different-date-formats-when-I-transpose-a-table/m-p/528494#M144250</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-01-19T03:02:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to handle different date formats when I transpose a table?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-handle-different-date-formats-when-I-transpose-a-table/m-p/528497#M144251</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Thanks, Tom.&amp;nbsp; This was the step that I was misunderstanding the most.&amp;nbsp; One I convert to characters, this seems to solve my problem:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;proc transpose data=Date_Formats;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;var var1 var2 var3;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 19 Jan 2019 03:35:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-handle-different-date-formats-when-I-transpose-a-table/m-p/528497#M144251</guid>
      <dc:creator>BarryP</dc:creator>
      <dc:date>2019-01-19T03:35:49Z</dc:date>
    </item>
  </channel>
</rss>

