<?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 transpose data like this? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-transpose-data-like-this/m-p/30874#M7367</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you have only one variable. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;



data have;
infile datalines length=len;
input a $varying200. len;
datalines;
a b 1 x1 y1 x2 y2
c d 2 x3 y3 x4 y4
;
run;
data want(keep=xx);
 set have;
 length x xx $ 400;
 i=4;
 x=catx(' ',scan(a,1),scan(a,2),scan(a,3));
 xx=catx(' ',x,scan(a,i),scan(a,i+1));
 do until(missing(scan(a,i)));
 output;
 i+2;
 xx=catx(' ',x,scan(a,i),scan(a,i+1));
 end;
run;

 
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 17 Jan 2012 09:53:01 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2012-01-17T09:53:01Z</dc:date>
    <item>
      <title>How to transpose data like this?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-transpose-data-like-this/m-p/30868#M7361</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I want to transpose the following data:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: tahoma, helvetica, clean, sans-serif; font-size: 12px; line-height: 20px; text-align: -webkit-auto; background-color: #ffffff;"&gt;a b 1 x1 y1 x2 y2 &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: tahoma, helvetica, clean, sans-serif; font-size: 12px; line-height: 20px; text-align: -webkit-auto; background-color: #ffffff;"&gt;c d 2 x3 y3 x4 y4;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: tahoma, helvetica, clean, sans-serif; font-size: 12px; line-height: 20px; text-align: -webkit-auto; background-color: #ffffff;"&gt;Into:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: tahoma, helvetica, clean, sans-serif; font-size: 12px; line-height: 20px; text-align: -webkit-auto; background-color: #ffffff;"&gt;a b 1 x1 y1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: tahoma, helvetica, clean, sans-serif; font-size: 12px; line-height: 20px; text-align: -webkit-auto; background-color: #ffffff;"&gt;a b 1 x2 y2&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: tahoma, helvetica, clean, sans-serif; font-size: 12px; line-height: 20px; text-align: -webkit-auto; background-color: #ffffff;"&gt;c d 2 x3 y3&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: tahoma, helvetica, clean, sans-serif; font-size: 12px; line-height: 20px; text-align: -webkit-auto; background-color: #ffffff;"&gt;c d 2 x4 y4;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: tahoma, helvetica, clean, sans-serif; font-size: 12px; line-height: 20px; text-align: -webkit-auto; background-color: #ffffff;"&gt;How to program?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: tahoma, helvetica, clean, sans-serif; font-size: 12px; line-height: 20px; text-align: -webkit-auto; background-color: #ffffff;"&gt;Thanks!&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: tahoma, helvetica, clean, sans-serif; font-size: 12px; line-height: 20px; text-align: -webkit-auto; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jan 2012 06:35:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-transpose-data-like-this/m-p/30868#M7361</guid>
      <dc:creator>MikeTurner</dc:creator>
      <dc:date>2012-01-17T06:35:21Z</dc:date>
    </item>
    <item>
      <title>How to transpose data like this?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-transpose-data-like-this/m-p/30869#M7362</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;These data are in TXT file ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;data want;
infile datalines dlm=' ' truncover;
input a $ b $ c $ d $ e $ @;
do until( missing(d)); 
 output;
 input d $ e $ @; 
end;
input;
datalines;
a b 1 x1 y1 x2 y2
c d 2 x3 y3 x4 y4
;
run;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jan 2012 06:51:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-transpose-data-like-this/m-p/30869#M7362</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-01-17T06:51:35Z</dc:date>
    </item>
    <item>
      <title>How to transpose data like this?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-transpose-data-like-this/m-p/30870#M7363</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks. But if the original data are in one datset, how to program it/&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jan 2012 08:13:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-transpose-data-like-this/m-p/30870#M7363</guid>
      <dc:creator>MikeTurner</dc:creator>
      <dc:date>2012-01-17T08:13:58Z</dc:date>
    </item>
    <item>
      <title>How to transpose data like this?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-transpose-data-like-this/m-p/30871#M7364</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You have Five variables or Only one variable to hold a record?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jan 2012 08:24:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-transpose-data-like-this/m-p/30871#M7364</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-01-17T08:24:42Z</dc:date>
    </item>
    <item>
      <title>How to transpose data like this?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-transpose-data-like-this/m-p/30872#M7365</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have seven variables in my original dataset. Now I want to hold a record (5 variables) using the first 3 variables.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jan 2012 09:17:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-transpose-data-like-this/m-p/30872#M7365</guid>
      <dc:creator>MikeTurner</dc:creator>
      <dc:date>2012-01-17T09:17:12Z</dc:date>
    </item>
    <item>
      <title>How to transpose data like this?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-transpose-data-like-this/m-p/30873#M7366</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;data have;
input (a1 - a7) (: $40.);
datalines;
a b 1 x1 y1 x2 y2
c d 2 x3 y3 x4 y4
;
run;
data want(drop=a4-a7);
 set have;
 x=a4;y=a5;output;
 x=a6;y=a7;output;
run;
&amp;nbsp; 


&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jan 2012 09:52:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-transpose-data-like-this/m-p/30873#M7366</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-01-17T09:52:00Z</dc:date>
    </item>
    <item>
      <title>How to transpose data like this?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-transpose-data-like-this/m-p/30874#M7367</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you have only one variable. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;



data have;
infile datalines length=len;
input a $varying200. len;
datalines;
a b 1 x1 y1 x2 y2
c d 2 x3 y3 x4 y4
;
run;
data want(keep=xx);
 set have;
 length x xx $ 400;
 i=4;
 x=catx(' ',scan(a,1),scan(a,2),scan(a,3));
 xx=catx(' ',x,scan(a,i),scan(a,i+1));
 do until(missing(scan(a,i)));
 output;
 i+2;
 xx=catx(' ',x,scan(a,i),scan(a,i+1));
 end;
run;

 
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jan 2012 09:53:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-transpose-data-like-this/m-p/30874#M7367</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-01-17T09:53:01Z</dc:date>
    </item>
  </channel>
</rss>

