<?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: Transposing Data for Analysis in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Transposing-Sas-dataset/m-p/887921#M350804</link>
    <description>&lt;P&gt;hi ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for the reply . Can we use proc transpose instead ? Also,&amp;nbsp;&lt;SPAN&gt;_1_1_2013 this is numeric column which has format and informat as BEST12.&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;&lt;SPAN&gt;Thank you&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 04 Aug 2023 16:50:40 GMT</pubDate>
    <dc:creator>jhh197</dc:creator>
    <dc:date>2023-08-04T16:50:40Z</dc:date>
    <item>
      <title>Transposing Sas dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transposing-Sas-dataset/m-p/887914#M350800</link>
      <description>&lt;P&gt;I have a dataset which looks like below .&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Date&lt;/TD&gt;&lt;TD&gt;PRICE_DS&lt;/TD&gt;&lt;TD&gt;Loc_typ&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;201301&lt;/TD&gt;&lt;TD&gt;65&lt;/TD&gt;&lt;TD&gt;25 MN SK&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;201303&lt;/TD&gt;&lt;TD&gt;65&lt;/TD&gt;&lt;TD&gt;25 MN SK&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;201310&lt;/TD&gt;&lt;TD&gt;65&lt;/TD&gt;&lt;TD&gt;25 MN SK&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;201312&lt;/TD&gt;&lt;TD&gt;65&lt;/TD&gt;&lt;TD&gt;25 MN SK&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;201401&lt;/TD&gt;&lt;TD&gt;65&lt;/TD&gt;&lt;TD&gt;25 MN SK&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;201402&lt;/TD&gt;&lt;TD&gt;65&lt;/TD&gt;&lt;TD&gt;25 MN SK&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;201301&lt;/TD&gt;&lt;TD&gt;79.25&lt;/TD&gt;&lt;TD&gt;SP NC KPP&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;201303&lt;/TD&gt;&lt;TD&gt;79.25&lt;/TD&gt;&lt;TD&gt;SP NC KPP&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;201310&lt;/TD&gt;&lt;TD&gt;79.25&lt;/TD&gt;&lt;TD&gt;SP NC KPP&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;201312&lt;/TD&gt;&lt;TD&gt;79.25&lt;/TD&gt;&lt;TD&gt;SP NC KPP&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;201401&lt;/TD&gt;&lt;TD&gt;79.25&lt;/TD&gt;&lt;TD&gt;SP NC KPP&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;201402&lt;/TD&gt;&lt;TD&gt;79.25&lt;/TD&gt;&lt;TD&gt;SP NC KPP&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;I want to create output like below . Can anyone please help ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Loc_typ&lt;/TD&gt;&lt;TD&gt;_1_1_2013&lt;/TD&gt;&lt;TD&gt;_3_1_2013&lt;/TD&gt;&lt;TD&gt;_10_1_2013&lt;/TD&gt;&lt;TD&gt;_12_1_2013&lt;/TD&gt;&lt;TD&gt;_1_1_2014&lt;/TD&gt;&lt;TD&gt;_2_1_2014&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;25 MN SK&lt;/TD&gt;&lt;TD&gt;65&lt;/TD&gt;&lt;TD&gt;65&lt;/TD&gt;&lt;TD&gt;65&lt;/TD&gt;&lt;TD&gt;65&lt;/TD&gt;&lt;TD&gt;65&lt;/TD&gt;&lt;TD&gt;65&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;SP NC KPP&lt;/TD&gt;&lt;TD&gt;79.25&lt;/TD&gt;&lt;TD&gt;79.25&lt;/TD&gt;&lt;TD&gt;79.25&lt;/TD&gt;&lt;TD&gt;79.25&lt;/TD&gt;&lt;TD&gt;79.25&lt;/TD&gt;&lt;TD&gt;79.25&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Fri, 04 Aug 2023 16:51:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transposing-Sas-dataset/m-p/887914#M350800</guid>
      <dc:creator>jhh197</dc:creator>
      <dc:date>2023-08-04T16:51:09Z</dc:date>
    </item>
    <item>
      <title>Re: Transposing Data for Analysis</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transposing-Sas-dataset/m-p/887917#M350801</link>
      <description>&lt;P&gt;Does not look useful for ANALYSIS.&lt;/P&gt;
&lt;P&gt;But if you want to see the data in the style for people to look at you could do it with a report.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report data=have ;
  columns loc_typ price_ds,date;
  define loc_typ / group;
   define date / across ' ';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Also your use of dates seems very confused.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does the original DATE variable have actual date values that is using the YYMMN6. format to display the date in that YYYYMM style?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or is it a character variable?&amp;nbsp; In which case use INPUT() with the YYMMN informat to convert the string into date values.&lt;/P&gt;
&lt;P&gt;Or perhaps a numeric variable that instead of having actual date values just has integers in YYY,YMM style?&amp;nbsp; If so then use PUT() and INPUT() functions to convert the number into a string that you can convert into a date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why would you want to display the dates in the headers using MDY order?&amp;nbsp; If you put dates into text (variable names are text) you should always use YMD order so the text values will sort in chronological order.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2023 16:23:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transposing-Sas-dataset/m-p/887917#M350801</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-08-04T16:23:29Z</dc:date>
    </item>
    <item>
      <title>Re: Transposing Data for Analysis</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transposing-Sas-dataset/m-p/887920#M350803</link>
      <description>&lt;P&gt;Agreeing with&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;, there's really no value in doing this transformation for ANALYSIS. So its very easy, don't transpose the data, and this part of the task is done.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Reporting is different.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2023 16:33:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transposing-Sas-dataset/m-p/887920#M350803</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-08-04T16:33:27Z</dc:date>
    </item>
    <item>
      <title>Re: Transposing Data for Analysis</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transposing-Sas-dataset/m-p/887921#M350804</link>
      <description>&lt;P&gt;hi ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for the reply . Can we use proc transpose instead ? Also,&amp;nbsp;&lt;SPAN&gt;_1_1_2013 this is numeric column which has format and informat as BEST12.&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;&lt;SPAN&gt;Thank you&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2023 16:50:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transposing-Sas-dataset/m-p/887921#M350804</guid>
      <dc:creator>jhh197</dc:creator>
      <dc:date>2023-08-04T16:50:40Z</dc:date>
    </item>
    <item>
      <title>Re: Transposing Data for Analysis</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transposing-Sas-dataset/m-p/887923#M350805</link>
      <description>Its just for transposing . I edited the message not for analysis</description>
      <pubDate>Fri, 04 Aug 2023 16:53:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transposing-Sas-dataset/m-p/887923#M350805</guid>
      <dc:creator>jhh197</dc:creator>
      <dc:date>2023-08-04T16:53:16Z</dc:date>
    </item>
    <item>
      <title>Re: Transposing Data for Analysis</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transposing-Sas-dataset/m-p/887926#M350807</link>
      <description>&lt;P&gt;So if you have a numeric variable named NUMBER with numbers like 202,303 and 202,210&amp;nbsp; and you want to convert them into the numeric variable named DATE with the dates '01MAR2023'd and '01OCT2022'd, respectively, then you could use PUT() and INPUT().&lt;/P&gt;
&lt;P&gt;Make sure to attach a date type format to the variable so the values print in a way that humans will understand.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;date = input(put(number,z6.),yymmn6.);
format date yymmdd10.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or you could use arithmetic and the MDY() function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;date = mdy(mod(number,100),1,int(number/100));
format date yymmdd10.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2023 17:24:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transposing-Sas-dataset/m-p/887926#M350807</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-08-04T17:24:01Z</dc:date>
    </item>
    <item>
      <title>Re: Transposing Data for Analysis</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transposing-Sas-dataset/m-p/887927#M350808</link>
      <description>&lt;P&gt;I would like to have the output like below . And the date field in input table looks like numeric and format7. And 201303 to _3_1_2013 numeric best12. Can i have the code in form of proc transpose ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Loc_typ&lt;/TD&gt;&lt;TD&gt;_1_1_2013&lt;/TD&gt;&lt;TD&gt;_3_1_2013&lt;/TD&gt;&lt;TD&gt;_10_1_2013&lt;/TD&gt;&lt;TD&gt;_12_1_2013&lt;/TD&gt;&lt;TD&gt;_1_1_2014&lt;/TD&gt;&lt;TD&gt;_2_1_2014&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;25 MN SK&lt;/TD&gt;&lt;TD&gt;65&lt;/TD&gt;&lt;TD&gt;65&lt;/TD&gt;&lt;TD&gt;65&lt;/TD&gt;&lt;TD&gt;65&lt;/TD&gt;&lt;TD&gt;65&lt;/TD&gt;&lt;TD&gt;65&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;SP NC KPP&lt;/TD&gt;&lt;TD&gt;79.25&lt;/TD&gt;&lt;TD&gt;79.25&lt;/TD&gt;&lt;TD&gt;79.25&lt;/TD&gt;&lt;TD&gt;79.25&lt;/TD&gt;&lt;TD&gt;79.25&lt;/TD&gt;&lt;TD&gt;79.25&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2023 17:28:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transposing-Sas-dataset/m-p/887927#M350808</guid>
      <dc:creator>jhh197</dc:creator>
      <dc:date>2023-08-04T17:28:11Z</dc:date>
    </item>
    <item>
      <title>Re: Transposing Data for Analysis</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transposing-Sas-dataset/m-p/887928#M350809</link>
      <description>&lt;P&gt;You could generate those gibberish variable names by first calculating MONTH, DAY and YEAR from the existing "date" variable and then using all three in the ID statement in PROC TRANSPOSE.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data for_transpose;
  set have;
  month = mod(date,100);
  day=1;
  year = int(date/100);
run;

proc transpose data=for_transpose out=want(drop=_name_) delim=_ prefix=_;
   by loc_typ;
   id month day year;
   var price_ds;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;By making separate variables PROC TRANSPOSE will convert them to strings and remove the leading and trailing spaces so you can get that strings that sometimes have one digit for the day or month value and sometimes have two digits.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If instead you want to make variable names that are easier to work with (and less confusing to figure out what date represent) why not just use the data directly?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=have out=want(drop=_name_) prefix=YM_;
   by loc_typ;
   id date;
   var price_ds;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So that you get variable named like YM_202301 and YM_202303.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2023 17:41:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transposing-Sas-dataset/m-p/887928#M350809</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-08-04T17:41:52Z</dc:date>
    </item>
    <item>
      <title>Re: Transposing Data for Analysis</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transposing-Sas-dataset/m-p/887941#M350811</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/89940"&gt;@jhh197&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Its just for transposing . I edited the message not for analysis&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Don't do it. The variable names would be a nightmare to use in any further programming. Please tell us what you plan to do with this data after transposing it?&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2023 18:47:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transposing-Sas-dataset/m-p/887941#M350811</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-08-04T18:47:25Z</dc:date>
    </item>
    <item>
      <title>Re: Transposing Data for Analysis</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transposing-Sas-dataset/m-p/887942#M350812</link>
      <description>&lt;P&gt;Thank you so much for all your help&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2023 18:55:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transposing-Sas-dataset/m-p/887942#M350812</guid>
      <dc:creator>jhh197</dc:creator>
      <dc:date>2023-08-04T18:55:42Z</dc:date>
    </item>
    <item>
      <title>Re: Transposing Data for Analysis</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transposing-Sas-dataset/m-p/887943#M350813</link>
      <description>&lt;P&gt;It creates output how i wanted it . Can we add the label like 3/1/2013 . When i click on properties of _3_1_2013&amp;nbsp; &amp;nbsp;it should show label as 3/1/2013 .&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for all your help&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2023 19:08:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transposing-Sas-dataset/m-p/887943#M350813</guid>
      <dc:creator>jhh197</dc:creator>
      <dc:date>2023-08-04T19:08:14Z</dc:date>
    </item>
    <item>
      <title>Re: Transposing Data for Analysis</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transposing-Sas-dataset/m-p/888010#M350844</link>
      <description>&lt;P&gt;This is sooooo much easier if you don't transpose in the first place. We can help you find easier ways to program this, if only you would tell us what you are trying to do (after you create this wide data set).&lt;/P&gt;</description>
      <pubDate>Sat, 05 Aug 2023 10:34:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transposing-Sas-dataset/m-p/888010#M350844</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-08-05T10:34:16Z</dc:date>
    </item>
  </channel>
</rss>

