<?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: Transpose in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Transpose/m-p/297505#M62484</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have;
	by place name qty:;
run;

data have1;
	retain id 0;
	set have;
	by place name;

	if first.name then
		id=1;
	else id=id+1;
run;

data have2;
	set have1;
	array ar_name (*) Qty:;
	do i=1 to dim(ar_name);
		new_col=cat(vname(ar_name[i]),'_',name);
		new_val=ar_name[i];
		output; /*put new_col= new_val=;*/
	end;

	drop i QTY: name;
run;

proc sort data=have2;
	by id new_col place;
run;

proc transpose data=have2 out=final(drop=id _NAME_);
	id new_col;
	by id place;
	var new_val;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 09 Sep 2016 22:27:05 GMT</pubDate>
    <dc:creator>Michiel</dc:creator>
    <dc:date>2016-09-09T22:27:05Z</dc:date>
    <item>
      <title>Transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transpose/m-p/297346#M62418</link>
      <description>&lt;P&gt;Hi Friends,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have requirement for transposing the data from Rows to columns. Please find the attched excel sheet for your reference.&lt;/P&gt;&lt;P&gt;Input sheet is the data can be used for input and output data is what i am expecting. Please help.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Sep 2016 09:50:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transpose/m-p/297346#M62418</guid>
      <dc:creator>sascodequestion</dc:creator>
      <dc:date>2016-09-09T09:50:22Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transpose/m-p/297348#M62419</link>
      <description>&lt;P&gt;That's an ugly format. Is this for a report or do you need a dataset?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The quickest way, least code is two proc transposes.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First transform your data to a long dataset, then you can re-transform to a wide dataset using different heading groups.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Sep 2016 09:57:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transpose/m-p/297348#M62419</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-09-09T09:57:34Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transpose/m-p/297353#M62421</link>
      <description>&lt;P&gt;please check the latest file uploaded&lt;/P&gt;</description>
      <pubDate>Fri, 09 Sep 2016 10:14:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transpose/m-p/297353#M62421</guid>
      <dc:creator>sascodequestion</dc:creator>
      <dc:date>2016-09-09T10:14:58Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transpose/m-p/297354#M62422</link>
      <description>&lt;P&gt;Hi, quick and dirty for this particular case:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA input;
   length name $1 place $4 qty1 qty2 qty3 3;
   input name place qty1 qty2 qty3;
   datalines;
   A USA1 1 2 3 
   A USA1 1 2 3 
   A USA1 1 2 3 
   A USA1 1 2 3 
   A USA1 1 2 3 
   B USA1 1 2 3 
   B USA1 1 2 3 
   B USA1 1 2 3 
   B USA1 1 2 3 
   B USA1 1 2 3 
   B USA1 1 2 3 
   B USA1 1 2 3
   ;
RUN;

PROC SORT data=input; by name place;RUN;
DATA input;
   length order 8;
   set input;
   retain order;
   by name place;
   if first.name then order=0;
   order+1;
RUN;

PROC SQL;&lt;BR /&gt;   CREATE TABLE OUTPUT AS
   SELECT a.name,
          a.place,
          a.qty1,
          a.qty2,
          a.qty3,
          b.name AS nameb,
          b.place AS placeb,
          b.qty1 AS qty1b,
          b.qty2 AS qty2b,
          b.qty3 AS qty3b
   FROM input(WHERE=(name eq 'A')) a
   FULL OUTER JOIN input(WHERE=(name eq 'B')) b 
   ON a.order eq b.order
   AND a.place eq b.place
   ;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 09 Sep 2016 11:01:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transpose/m-p/297354#M62422</guid>
      <dc:creator>Oligolas</dc:creator>
      <dc:date>2016-09-09T11:01:26Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transpose/m-p/297358#M62424</link>
      <description>&lt;PRE&gt;
Plz post data at here . No one would like to download a file .

Check MERGE skill proposed by Me,Matt,Arthur.T :
http://support.sas.com/resources/papers/proceedings15/2785-2015.pdf



data have;
infile cards expandtabs truncover;
input Name $	Place &amp;amp; $	Qty1 	Qty2	Qty3;
cards;
A	USA 1	1	2	3
A	USA 1	1	2	3
A	USA 1	1	2	3
A	USA 1	1	2	3
A	USA 1	1	2	3
B	USA 1	1	2	3
B	USA 1	1	2	3
B	USA 1	1	2	3
B	USA 1	1	2	3
B	USA 1	1	2	3
B	USA 1	1	2	3
B	USA 1	1	2	3
;
run;
proc sql ;
select distinct catt('have(where=(name="',name,'")
 rename=(qty1=qty1_',name,' qty2=qty2_',name,' qty3=qty3_',name,') )')
 into : merge separated by ' ' 
 from have
  order by 1 desc;
quit;

data want;
 merge &amp;amp;merge ;
 by place;
 output;
 call missing(of _all_);
run;





&lt;/PRE&gt;</description>
      <pubDate>Fri, 09 Sep 2016 10:23:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transpose/m-p/297358#M62424</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-09-09T10:23:40Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transpose/m-p/297393#M62431</link>
      <description>&lt;P&gt;Hello Ksharp,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your solutions fits exactly as i expected. Only thing is i have some problem with catx function. when i am using fpr morethan 5 qty variables i am getting below warnign generated and the output also not as expected.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;WARNING: In a call to the CATT function, the buffer allocated for the result was not long enough to contain the concatenation of&lt;BR /&gt;all the arguments. The correct result would contain 219 characters, but the actual result might either be truncated to 200&lt;BR /&gt;character(s) or be completely blank, depending on the calling environment. The following note indicates the left-most&lt;BR /&gt;argument that caused truncation&lt;/P&gt;</description>
      <pubDate>Fri, 09 Sep 2016 13:39:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transpose/m-p/297393#M62431</guid>
      <dc:creator>sascodequestion</dc:creator>
      <dc:date>2016-09-09T13:39:02Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transpose/m-p/297412#M62444</link>
      <description>&lt;P&gt;Many users here don't want to download Excel files because of virus potential, others have such things blocked by security software. Also if you give us Excel we have to create a SAS data set and due to the non-existent constraints on Excel data cells the result we end up with may not have variables of the same type (numeric or character) and even values.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Sep 2016 14:55:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transpose/m-p/297412#M62444</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-09-09T14:55:37Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transpose/m-p/297505#M62484</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have;
	by place name qty:;
run;

data have1;
	retain id 0;
	set have;
	by place name;

	if first.name then
		id=1;
	else id=id+1;
run;

data have2;
	set have1;
	array ar_name (*) Qty:;
	do i=1 to dim(ar_name);
		new_col=cat(vname(ar_name[i]),'_',name);
		new_val=ar_name[i];
		output; /*put new_col= new_val=;*/
	end;

	drop i QTY: name;
run;

proc sort data=have2;
	by id new_col place;
run;

proc transpose data=have2 out=final(drop=id _NAME_);
	id new_col;
	by id place;
	var new_val;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 09 Sep 2016 22:27:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transpose/m-p/297505#M62484</guid>
      <dc:creator>Michiel</dc:creator>
      <dc:date>2016-09-09T22:27:05Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transpose/m-p/297521#M62491</link>
      <description>&lt;PRE&gt;
You could try define a larger length than 200:





data have;
infile cards expandtabs truncover;
input Name $	Place &amp;amp; $	Qty1 	Qty2	Qty3;
cards;
A	USA 1	1	2	3
A	USA 1	1	2	3
A	USA 1	1	2	3
A	USA 1	1	2	3
A	USA 1	1	2	3
B	USA 1	1	2	3
B	USA 1	1	2	3
B	USA 1	1	2	3
B	USA 1	1	2	3
B	USA 1	1	2	3
B	USA 1	1	2	3
B	USA 1	1	2	3
;
run;
proc sql ;
select distinct catt('have(where=(name="',name,'")
 rename=(qty1=qty1_',name,' qty2=qty2_',name,' qty3=qty3_',name,') )')
 as merge length=400
 into : merge separated by ' '
 from have
  order by 1 desc;
quit;

data want;
 merge &amp;amp;merge ;
 by place;
 output;
 call missing(of _all_);
run;
&lt;/PRE&gt;</description>
      <pubDate>Sat, 10 Sep 2016 02:19:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transpose/m-p/297521#M62491</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-09-10T02:19:14Z</dc:date>
    </item>
  </channel>
</rss>

