<?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: proc transpose on multiple columns in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-transpose-on-multiple-columns/m-p/626879#M184950</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want the final set to like that:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
input Name_ID Type $ Price_2016 Pieces_2016 Price_2017 Pieces_2017 Price_2018 Pieces_2018;
datalines;
1 Aa . . 100 . 30 11
1 Bb . . 200 3 40 32
2 Aa . . . . 50 5
2 Cc 80 4 500 2 10 6
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So, persist the order of the base-columns but start with the smallest year.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 24 Feb 2020 15:00:51 GMT</pubDate>
    <dc:creator>Emjay</dc:creator>
    <dc:date>2020-02-24T15:00:51Z</dc:date>
    <item>
      <title>proc transpose on multiple columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-transpose-on-multiple-columns/m-p/626828#M184928</link>
      <description>&lt;P&gt;I have a table in the following form: (Actually there are 10 Years and the columns don't end after Pieces, but I hope for the question it's fine.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Year Name_ID Type $ Price Pieces;
datalines;
2017 1 Aa 100 .
2017 1 Bb 200 3
2017 2 Cc 500 2
2018 1 Aa 30 11
2018 1 Bb 40 32
2018 2 Aa 50 5
2018 2 Cc 10 6
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What I want is to transpose the data to the following form:&lt;/P&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;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
input Name_ID Type $ Price_2017 Pieces_2017 Price_2018 Pieces_2018;
datalines;
1 Aa 100 . 30 11
1 Bb 200 3 40 32
2 Aa . . 50 5
2 Cc 500 2 10 6
;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've done this before on a different dataset with a transpose for every single column and merged them together. But now I have a lot of columns and I don't want to do this manually. And another downside is, that after the merge, the columns aren't in the proper order either and the retain would need a lot of typing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you please help me in finding a smarter way?&lt;/P&gt;</description>
      <pubDate>Mon, 24 Feb 2020 10:27:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-transpose-on-multiple-columns/m-p/626828#M184928</guid>
      <dc:creator>Emjay</dc:creator>
      <dc:date>2020-02-24T10:27:44Z</dc:date>
    </item>
    <item>
      <title>Re: proc transpose on multiple columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-transpose-on-multiple-columns/m-p/626833#M184929</link>
      <description>&lt;P&gt;&lt;EM&gt;"&lt;/EM&gt;&lt;SPAN&gt;&lt;EM&gt;the columns aren't in the proper order"&lt;/EM&gt;. This makes me wonder if this is for reporting purposes or you actually need a data set for this?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Feb 2020 11:23:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-transpose-on-multiple-columns/m-p/626833#M184929</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-02-24T11:23:18Z</dc:date>
    </item>
    <item>
      <title>Re: proc transpose on multiple columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-transpose-on-multiple-columns/m-p/626834#M184930</link>
      <description>&lt;P&gt;I have to provide the output to my colleagues in Excel and there it has to be like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;Price_2017 Pieces_2017 Price_2018 Pieces_2018&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and not:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;Price_2017 Price_2018 Pieces_2017 Pieces_2018&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;That's what I mean with the not propper order.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Feb 2020 11:28:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-transpose-on-multiple-columns/m-p/626834#M184930</guid>
      <dc:creator>Emjay</dc:creator>
      <dc:date>2020-02-24T11:28:51Z</dc:date>
    </item>
    <item>
      <title>Re: proc transpose on multiple columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-transpose-on-multiple-columns/m-p/626836#M184932</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/202610"&gt;@Emjay&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is an approach to do this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have out=have_sorted;
	by Name_ID Type Year;
run;

/* Create macrovariables */
proc sql noprint;
	select min(Year), max(Year) into: min_year trimmed,:max_year trimmed from have;
	select name into:name1-  from dictionary.columns where libname="WORK" and memname= "HAVE"
		   and name not in('Year', 'Name_ID', 'Type');
	select name into:variables_sp separated by ' ' from dictionary.columns where libname="WORK" and memname= "HAVE"
		   and name not in('Year', 'Name_ID', 'Type');
	select count(name) into:nb from dictionary.columns where libname="WORK" and memname= "HAVE"
		   and name not in('Year', 'Name_ID', 'Type');
run;
		/* &amp;amp;min_year = 2017 */
		/* &amp;amp;max_year = 2018 */
		/* &amp;amp;name1 = price */
		/* &amp;amp;name2 = pieces */
		/* &amp;amp;variables_sp = Price Pieces*/
		/* &amp;amp;nb = 2*/

%macro _tr();
	
	/* Transpose data */
	
	data have_tr (drop=counter year &amp;amp;variables_sp);
	
		set have_sorted;
		by Name_ID Type;

		if first.Type then call missing (counter);
	
		%do i=1 %to &amp;amp;nb;
	
			array _&amp;amp;&amp;amp;name&amp;amp;i. (&amp;amp;min_year:&amp;amp;max_year) &amp;amp;&amp;amp;name&amp;amp;i.._&amp;amp;min_year - &amp;amp;&amp;amp;name&amp;amp;i.._&amp;amp;max_year;
			retain _&amp;amp;&amp;amp;name&amp;amp;i.;
 			if first.Type then call missing (counter, of _&amp;amp;&amp;amp;name&amp;amp;i.(*));
 			counter+1;	
			_&amp;amp;&amp;amp;name&amp;amp;i.(year) = &amp;amp;&amp;amp;name&amp;amp;i.;

		%end;
	
		if last.Type then output;
	run;
	
	/* Re-order variables */
	
	proc sql noprint;
		select name into:var_keep separated by ',' from dictionary.columns where libname="WORK" and memname= "HAVE_TR" and name not in('Year', 'Name_ID', 'Type') order by scan(name,2,'_'), name desc; 
		create table want as select Name_ID, Type, &amp;amp;var_keep. from have_tr;
	quit;
%mend;

%_tr;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture d’écran 2020-02-24 à 12.35.20.png" style="width: 533px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/36350i9AF48070F568653E/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture d’écran 2020-02-24 à 12.35.20.png" alt="Capture d’écran 2020-02-24 à 12.35.20.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Feb 2020 11:42:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-transpose-on-multiple-columns/m-p/626836#M184932</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-02-24T11:42:47Z</dc:date>
    </item>
    <item>
      <title>Re: proc transpose on multiple columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-transpose-on-multiple-columns/m-p/626845#M184935</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292097"&gt;@ed_sas_member&lt;/a&gt;&amp;nbsp;thanks for your help!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm not really familiar with the array-function, so I don't understand all of your code, but it looks fine. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there no easy way to do it with a transpose, or is array just nicer?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The only problem is, that I have columns that already contain a "_" in the beginning, or even more than one. So the scan is not really working. I may have to change the original names then...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Feb 2020 12:37:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-transpose-on-multiple-columns/m-p/626845#M184935</guid>
      <dc:creator>Emjay</dc:creator>
      <dc:date>2020-02-24T12:37:53Z</dc:date>
    </item>
    <item>
      <title>Re: proc transpose on multiple columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-transpose-on-multiple-columns/m-p/626846#M184936</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/202610"&gt;@Emjay&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You're welcome.&lt;/P&gt;
&lt;P&gt;You can also obtain a similar output using multiple PROC TRANSPOSE (one transpose pieces, another to transpose price, ...) and then merge the results. The only 'difficulty' is to label the new columns (price2017, ...).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regarding, the last part of the code, using a proc sql to rearrange columns, I suggest that you use another function than the SCAN function to identify variable ending with the year (e.. SUBSTR, etc.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Feb 2020 12:44:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-transpose-on-multiple-columns/m-p/626846#M184936</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-02-24T12:44:23Z</dc:date>
    </item>
    <item>
      <title>Re: proc transpose on multiple columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-transpose-on-multiple-columns/m-p/626853#M184937</link>
      <description>&lt;P&gt;Well labeling was not the problem, but sorting was. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; I just thought there may be a nicer way to it, than writing a proc transpose for every single column.&lt;/P&gt;
&lt;P&gt;I didn't think about substr. I'll try that later, thanks.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Feb 2020 13:08:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-transpose-on-multiple-columns/m-p/626853#M184937</guid>
      <dc:creator>Emjay</dc:creator>
      <dc:date>2020-02-24T13:08:21Z</dc:date>
    </item>
    <item>
      <title>Re: proc transpose on multiple columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-transpose-on-multiple-columns/m-p/626857#M184940</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/202610"&gt;@Emjay&lt;/a&gt;&amp;nbsp; Good morning and Sorry my late entry to the part as I have been away for a few days missing all the excitement here. If I understand your requirement correctly, all you need is a very simple double transpose. Of course, your data must be sorted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So,in SAS words&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Year Name_ID Type $ Price Pieces;
datalines;
2017 1 Aa 100 .
2017 1 Bb 200 3
2017 2 Cc 500 2
2018 1 Aa 30 11
2018 1 Bb 40 32
2018 2 Aa 50 5
2018 2 Cc 10 6
;
run;

proc sort data=have out=_have;
by name_id type year;
run;
proc transpose data=_have out=temp;
by name_id type year;
var price pieces;
run;

proc transpose data=temp out=want(drop=_:);
by  name_id type;
id _name_ year;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Feb 2020 13:24:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-transpose-on-multiple-columns/m-p/626857#M184940</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-02-24T13:24:30Z</dc:date>
    </item>
    <item>
      <title>Re: proc transpose on multiple columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-transpose-on-multiple-columns/m-p/626863#M184944</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;this looks like the thing I had in mind. I never really manage to get my head around when to use ID and when it's not needed. &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any idea on how I can get a "_" between the names in the transpose? So that there is Price_2017 and not Price2017.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Feb 2020 13:49:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-transpose-on-multiple-columns/m-p/626863#M184944</guid>
      <dc:creator>Emjay</dc:creator>
      <dc:date>2020-02-24T13:49:37Z</dc:date>
    </item>
    <item>
      <title>Re: proc transpose on multiple columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-transpose-on-multiple-columns/m-p/626864#M184945</link>
      <description>&lt;P&gt;HI&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/202610"&gt;@Emjay&lt;/a&gt;&amp;nbsp; Oh sorry I forgot to add the delimiter option,&amp;nbsp; Please notice the Revised with &lt;STRONG&gt;delimiter&lt;/STRONG&gt; option in the 2nd transpose step&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have out=_have;
by name_id type year;
run;
proc transpose data=_have out=temp;
by name_id type year;
var price pieces;
run;

proc transpose data=temp out=want(drop=_:) delimiter=_;
by  name_id type;
id _name_ year;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Feb 2020 13:53:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-transpose-on-multiple-columns/m-p/626864#M184945</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-02-24T13:53:38Z</dc:date>
    </item>
    <item>
      <title>Re: proc transpose on multiple columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-transpose-on-multiple-columns/m-p/626867#M184947</link>
      <description>Cool, thanks!&lt;BR /&gt;</description>
      <pubDate>Mon, 24 Feb 2020 13:57:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-transpose-on-multiple-columns/m-p/626867#M184947</guid>
      <dc:creator>Emjay</dc:creator>
      <dc:date>2020-02-24T13:57:36Z</dc:date>
    </item>
    <item>
      <title>Re: proc transpose on multiple columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-transpose-on-multiple-columns/m-p/626873#M184948</link>
      <description>&lt;P&gt;Sorry to bother you again &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt; but I came across an issue, when I ran your code on my whole data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've made a small adaption and added line number 3 with the year 2016. Since the year is not present for Name_ID 1 the order in the final data set ist not ascending anymore.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Year Name_ID Type $ Price Pieces;
datalines;
2017 1 Aa 100 .
2017 1 Bb 200 3
2016 2 Cc 80 4
2017 2 Cc 500 2
2018 1 Aa 30 11
2018 1 Bb 40 32
2018 2 Aa 50 5
2018 2 Cc 10 6
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I change the first sort and start with year, it will fail in the end due to wrong sorting. I thought about maybe adding some fake data with all years and deleting it later. Can you maybe think of something more elegant?&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Feb 2020 14:38:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-transpose-on-multiple-columns/m-p/626873#M184948</guid>
      <dc:creator>Emjay</dc:creator>
      <dc:date>2020-02-24T14:38:56Z</dc:date>
    </item>
    <item>
      <title>Re: proc transpose on multiple columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-transpose-on-multiple-columns/m-p/626878#M184949</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/202610"&gt;@Emjay&lt;/a&gt;&amp;nbsp; No bother at all and don't have to be so formal. Can you also illustrate/show the expected output for the modified one. I have some assumptions, but before playing with assumptions I believe it's better to know what you want as output for quicker solutions&lt;/P&gt;</description>
      <pubDate>Mon, 24 Feb 2020 14:53:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-transpose-on-multiple-columns/m-p/626878#M184949</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-02-24T14:53:24Z</dc:date>
    </item>
    <item>
      <title>Re: proc transpose on multiple columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-transpose-on-multiple-columns/m-p/626879#M184950</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want the final set to like that:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
input Name_ID Type $ Price_2016 Pieces_2016 Price_2017 Pieces_2017 Price_2018 Pieces_2018;
datalines;
1 Aa . . 100 . 30 11
1 Bb . . 200 3 40 32
2 Aa . . . . 50 5
2 Cc 80 4 500 2 10 6
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So, persist the order of the base-columns but start with the smallest year.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Feb 2020 15:00:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-transpose-on-multiple-columns/m-p/626879#M184950</guid>
      <dc:creator>Emjay</dc:creator>
      <dc:date>2020-02-24T15:00:51Z</dc:date>
    </item>
    <item>
      <title>Re: proc transpose on multiple columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-transpose-on-multiple-columns/m-p/626921#M184966</link>
      <description>&lt;P&gt;I am gonna seek Guru&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15410"&gt;@data_null__&lt;/a&gt;'s help if he doesn't mind..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Guru &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15410"&gt;@data_null__&lt;/a&gt;&amp;nbsp;, If you don;t mind, can you give us a hand in getting the correct combination in TYPES/WAYS in Proc Summary to get all year values for each ID TYPE _NAME_ independent group.&amp;nbsp; The idea is to avoid a cartesian(SQL) or any datastep programming fix rather to use Proc summary options before the proc transpose so that we get the missing years and the years in order just how OP wants.&amp;nbsp; &amp;nbsp;Once you could help this part, then it's the same transpose after. The completetypes pulls the unintended types and ID's and my mind is not working well. May i request your time plz . Thank you*1e6 in advance.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Feb 2020 17:28:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-transpose-on-multiple-columns/m-p/626921#M184966</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-02-24T17:28:39Z</dc:date>
    </item>
    <item>
      <title>Re: proc transpose on multiple columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-transpose-on-multiple-columns/m-p/626948#M184976</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt; I think this is what you need.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Year Name_ID Type $ Price Pieces;
datalines;
2017 1 Aa 100 .
2017 1 Bb 200 3
2016 2 Cc 80 4
2017 2 Cc 500 2
2018 1 Aa 30 11
2018 1 Bb 40 32
2018 2 Aa 50 5
2018 2 Cc 10 6
;
run;
proc sort data=have;
   by name_id type year;
   run;
proc print;
   run;
proc summary data=have nway missing completetypes;
   class type year;
   output out=_have;
   run;
data _have;
   set _have have;
   run;
proc transpose data=_have out=temp;
   by name_id type year;
   var price pieces;
   run;
proc transpose data=temp out=want(drop=_: where=(not missing(name_id))) delimiter=_;
   by  name_id type;
   id _name_ year;
   run;
proc print;
   run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/36356i5CA9900E6CF27BCF/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Feb 2020 18:28:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-transpose-on-multiple-columns/m-p/626948#M184976</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2020-02-24T18:28:34Z</dc:date>
    </item>
    <item>
      <title>Re: proc transpose on multiple columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-transpose-on-multiple-columns/m-p/626974#M184987</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15410"&gt;@data_null__&lt;/a&gt;&amp;nbsp; Wow, thanks for your help guys! Very nice way.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Feb 2020 19:15:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-transpose-on-multiple-columns/m-p/626974#M184987</guid>
      <dc:creator>Emjay</dc:creator>
      <dc:date>2020-02-24T19:15:18Z</dc:date>
    </item>
    <item>
      <title>Re: proc transpose on multiple columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-transpose-on-multiple-columns/m-p/626978#M184989</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/202610"&gt;@Emjay&lt;/a&gt;&amp;nbsp; If I would pay somebody to read their content, Guru is right up there. Let me also add my thanks to yours.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15410"&gt;@data_null__&lt;/a&gt;&amp;nbsp; Guru thankkkkkkkkkkkkkkkkkkkkkkkk youuuuuuuuuuuuuuuuuuuuuuuuuuuu!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!&amp;nbsp; as always&lt;/P&gt;</description>
      <pubDate>Mon, 24 Feb 2020 19:18:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-transpose-on-multiple-columns/m-p/626978#M184989</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-02-24T19:18:38Z</dc:date>
    </item>
  </channel>
</rss>

