<?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 Help in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Transpose-Help/m-p/537355#M6760</link>
    <description>&lt;P&gt;Or you use a custom data step:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data VS;
input usubjid weight weightu $ temp tempu $ hr hru $ visit $ dd mm yy;
datalines;
100 102 KG 38 C 70 BEATS/MIN WEEK1 01 01 2000 
100 225 KG 97 F 71 BEATS/MIN WEEK2 14 01 2000 
100 112 KG 38 C 72 BEATS/MIN WEEK3 28 01 2000 
100 102 KG 38 C 72 BEATS/MIN WEEK4 07 02 2000 
101 220 KG 98.6 C 75 BEATS/MIN WEEK1 01 01 2000 
101 102 KG 38 C 72 BEATS/MIN WEEK2 14 01 2000 
101 104 KG 38 C 73 BEATS/MIN WEEK3 28 01 2000 
;
run;

data want;
set vs;
array units {3} weightu hru tempu;
array values {3} weight hr temp;
do i = 1 to 3;
  unit = units{i};
  value = values{i};
  output;
end;
keep usubjid unit value visit dd mm yy;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 21 Feb 2019 09:50:33 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2019-02-21T09:50:33Z</dc:date>
    <item>
      <title>Transpose Help</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Transpose-Help/m-p/537346#M6757</link>
      <description>&lt;P&gt;Hello Everyone,&lt;/P&gt;&lt;P&gt;I am trying to transpose this dataset but don't know how to transpose weightu, tempu and hru under one variable name "UNIT" (these are the units for weight, temp and hr respectively) along with the respective observation. Please help!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data VS;&lt;BR /&gt;input usubjid weight weightu $ temp tempu $ hr hru $ visit $ dd mm yy;&lt;BR /&gt;datalines;&lt;BR /&gt;100 102 KG 38 C 70 BEATS/MIN WEEK1 01 01 2000&amp;nbsp;&lt;BR /&gt;100 225 KG 97 F 71 BEATS/MIN WEEK2 14 01 2000&amp;nbsp;&lt;BR /&gt;100 112 KG 38 C 72 BEATS/MIN WEEK3 28 01 2000&amp;nbsp;&lt;BR /&gt;100 102 KG 38 C 72 BEATS/MIN WEEK4 07 02 2000&amp;nbsp;&lt;BR /&gt;101 220 KG 98.6 C 75 BEATS/MIN WEEK1 01 01 2000&amp;nbsp;&lt;BR /&gt;101 102 KG 38 C 72 BEATS/MIN WEEK2 14 01 2000&amp;nbsp;&lt;BR /&gt;101 104 KG 38 C 73 BEATS/MIN WEEK3 28 01 2000&amp;nbsp;&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;proc sort data=vs out=sorted_vs;&lt;BR /&gt;by usubjid visit dd mm yy;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc transpose data=sorted_vs out=transp_vs&amp;nbsp;name=TESTCD prefix=results;&lt;BR /&gt;by usubjid visit dd mm yy;&lt;BR /&gt;var weight temp hr;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Feb 2019 09:14:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Transpose-Help/m-p/537346#M6757</guid>
      <dc:creator>Jane_V</dc:creator>
      <dc:date>2019-02-21T09:14:49Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose Help</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Transpose-Help/m-p/537352#M6759</link>
      <description>&lt;P&gt;you need to add two more steps to your code to get the units&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 VS;
input usubjid weight weightu $ temp tempu $ hr hru $ visit $ dd mm yy;
datalines;
100 102 KG 38 C 70 BEATS/MIN WEEK1 01 01 2000 
100 225 KG 97 F 71 BEATS/MIN WEEK2 14 01 2000 
100 112 KG 38 C 72 BEATS/MIN WEEK3 28 01 2000 
100 102 KG 38 C 72 BEATS/MIN WEEK4 07 02 2000 
101 220 KG 98.6 C 75 BEATS/MIN WEEK1 01 01 2000 
101 102 KG 38 C 72 BEATS/MIN WEEK2 14 01 2000 
101 104 KG 38 C 73 BEATS/MIN WEEK3 28 01 2000 
;
run;

proc sort data=vs out=sorted_vs;
by usubjid visit dd mm yy;
run;

proc transpose data=sorted_vs out=transp_vs name=TESTCD prefix=results;
by usubjid visit dd mm yy;
var weight temp hr;
run;

&lt;STRONG&gt;proc transpose data=sorted_vs out=transp_vs2 name=TESTCD prefix=units;
by usubjid visit dd mm yy;
var weightu tempu hru;
run;

data all;
merge transp_vs transp_vs2;
by usubjid visit dd mm yy;
run;
&lt;/STRONG&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Feb 2019 09:45:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Transpose-Help/m-p/537352#M6759</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2019-02-21T09:45:26Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose Help</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Transpose-Help/m-p/537355#M6760</link>
      <description>&lt;P&gt;Or you use a custom data step:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data VS;
input usubjid weight weightu $ temp tempu $ hr hru $ visit $ dd mm yy;
datalines;
100 102 KG 38 C 70 BEATS/MIN WEEK1 01 01 2000 
100 225 KG 97 F 71 BEATS/MIN WEEK2 14 01 2000 
100 112 KG 38 C 72 BEATS/MIN WEEK3 28 01 2000 
100 102 KG 38 C 72 BEATS/MIN WEEK4 07 02 2000 
101 220 KG 98.6 C 75 BEATS/MIN WEEK1 01 01 2000 
101 102 KG 38 C 72 BEATS/MIN WEEK2 14 01 2000 
101 104 KG 38 C 73 BEATS/MIN WEEK3 28 01 2000 
;
run;

data want;
set vs;
array units {3} weightu hru tempu;
array values {3} weight hr temp;
do i = 1 to 3;
  unit = units{i};
  value = values{i};
  output;
end;
keep usubjid unit value visit dd mm yy;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Feb 2019 09:50:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Transpose-Help/m-p/537355#M6760</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-02-21T09:50:33Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose Help</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Transpose-Help/m-p/537357#M6761</link>
      <description>&lt;P&gt;another approach would be with arrays which is the simplest&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data VS;
input usubjid weight weightu $ temp tempu $ hr hru $ visit $ dd mm yy;
datalines;
100 102 KG 38 C 70 BEATS/MIN WEEK1 01 01 2000 
100 225 KG 97 F 71 BEATS/MIN WEEK2 14 01 2000 
100 112 KG 38 C 72 BEATS/MIN WEEK3 28 01 2000 
100 102 KG 38 C 72 BEATS/MIN WEEK4 07 02 2000 
101 220 KG 98.6 C 75 BEATS/MIN WEEK1 01 01 2000 
101 102 KG 38 C 72 BEATS/MIN WEEK2 14 01 2000 
101 104 KG 38 C 73 BEATS/MIN WEEK3 28 01 2000 
;
run;

proc sort data=vs out=sorted_vs;
by usubjid visit dd mm yy;
run;

data want;
set vs;
by usubjid visit dd mm yy;
array testcds(3) weight temp hr;
array testu(3)$ weightu tempu hru;
array testlbl(3)$ ('weight' 'temp' 'hr');
do i = 1 to 3;
if first.yy then testcd=testlbl(i);
if first.yy then result=testcds(i);
if first.yy then units=testu(i);
output;
end;
drop testlbl: i;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Feb 2019 09:53:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Transpose-Help/m-p/537357#M6761</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2019-02-21T09:53:38Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose Help</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Transpose-Help/m-p/537359#M6762</link>
      <description>&lt;P&gt;You would need a few transposes to do it like that. Easier with arrays:&lt;/P&gt;
&lt;PRE&gt;data vs;
  input usubjid weight weightu $ temp tempu $ hr hru $ visit $ dd mm yy;
datalines;
100 102 KG 38 C 70 BEATS/MIN WEEK1 01 01 2000 
100 225 KG 97 F 71 BEATS/MIN WEEK2 14 01 2000 
100 112 KG 38 C 72 BEATS/MIN WEEK3 28 01 2000 
100 102 KG 38 C 72 BEATS/MIN WEEK4 07 02 2000 
101 220 KG 98.6 C 75 BEATS/MIN WEEK1 01 01 2000 
101 102 KG 38 C 72 BEATS/MIN WEEK2 14 01 2000 
101 104 KG 38 C 73 BEATS/MIN WEEK3 28 01 2000 
;
run;

proc sort data=vs out=sorted_vs;
  by usubjid visit dd mm yy;
run;

data want (keep=usubjid visit dd mm yy paramcd aval paru);
  set sorted_vs;
  array test{3} weight temp hr;
  array unit{3} weightu tempu hru;
  do i=1 to 3;
    paramcd=vname(test{i});
    aval=test{i};
    paru=unit{i};
    output;
  end;
run;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Feb 2019 10:02:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Transpose-Help/m-p/537359#M6762</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2019-02-21T10:02:56Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose Help</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Transpose-Help/m-p/537572#M6790</link>
      <description>&lt;P&gt;Thank you everyone!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;At this novice stage, all the solutions (with/ without proc transpose) are really helpful to learn SAS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best!&lt;/P&gt;</description>
      <pubDate>Fri, 22 Feb 2019 01:09:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Transpose-Help/m-p/537572#M6790</guid>
      <dc:creator>Jane_V</dc:creator>
      <dc:date>2019-02-22T01:09:16Z</dc:date>
    </item>
  </channel>
</rss>

