<?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 multiple variables from multiple time points. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Transposing-multiple-variables-from-multiple-time-points/m-p/356668#M83648</link>
    <description>&lt;P&gt;For your arrays are you more likely to do your analysis by site or time period? Which ever one is more common should be the first prefix in your variable. SAS can use prefixes to reference a variable list, which is why you'd want to factor this into your decision making.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 07 May 2017 00:30:49 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-05-07T00:30:49Z</dc:date>
    <item>
      <title>Transposing multiple variables from multiple time points.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transposing-multiple-variables-from-multiple-time-points/m-p/356659#M83642</link>
      <description>&lt;P&gt;I am trying to transpose a dataset that looks like&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;SUBJ VISIT SITE1 SITE2 SITE3&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3.5 &amp;nbsp; &amp;nbsp; 4.5 &amp;nbsp; &amp;nbsp; &amp;nbsp;2.5&amp;nbsp;&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3.6 &amp;nbsp; &amp;nbsp; 4.6 &amp;nbsp; &amp;nbsp; &amp;nbsp;2.2&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3.4 &amp;nbsp; &amp;nbsp; 3.2 &amp;nbsp; &amp;nbsp; &amp;nbsp;2.1&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;4.5 &amp;nbsp; &amp;nbsp; 5.2 &amp;nbsp; &amp;nbsp; &amp;nbsp;4.4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And I want it to look like&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;SUBJ &amp;nbsp;SITE1.1 SITE2.1 &amp;nbsp; SITE3.1&amp;nbsp;SITE1.2 SITE2.2 SITE3.2&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3.5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;4.5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2.5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3.6 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;4.6 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2.2&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3.4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3.2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2.1 &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;4.5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5.2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 4.4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want keep the existing varible names, but add .(visit) to the name to identify the visit.&lt;/P&gt;&lt;P&gt;I can only find ways to do one variable at a time, but need to transpose poses 30 variables with several time points.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thinks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;John.&lt;/P&gt;</description>
      <pubDate>Sat, 06 May 2017 23:16:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transposing-multiple-variables-from-multiple-time-points/m-p/356659#M83642</guid>
      <dc:creator>Jbhammon</dc:creator>
      <dc:date>2017-05-06T23:16:11Z</dc:date>
    </item>
    <item>
      <title>Re: Transposing multiple variables from multiple time points.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transposing-multiple-variables-from-multiple-time-points/m-p/356663#M83644</link>
      <description>&lt;P&gt;I suggest using the transpose macro you can find at:&amp;nbsp;&lt;A href="http://www.sascommunity.org/wiki/A_Better_Way_to_Flip_(Transpose)_a_SAS_Dataset" target="_blank"&gt;http://www.sascommunity.org/wiki/A_Better_Way_to_Flip_(Transpose)_a_SAS_Dataset&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;after downloading and running it, you would only have to run something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;
  input SUBJ VISIT SITE1 SITE2 SITE3 test1 test2 test3;
  cards;
1        1        3.5     4.5      2.5 1 2 3
1        2        3.6     4.6      2.2 3 2 1
2        1        3.4     3.2      2.1 4 5 6
2        2        4.5     5.2      4.4 6 5 4
;
%transpose(data=have, out=want, by=subj, id=visit,
   delimiter=_, var=site1--test3)
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;</description>
      <pubDate>Sat, 06 May 2017 23:48:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transposing-multiple-variables-from-multiple-time-points/m-p/356663#M83644</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-05-06T23:48:23Z</dc:date>
    </item>
    <item>
      <title>Re: Transposing multiple variables from multiple time points.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transposing-multiple-variables-from-multiple-time-points/m-p/356665#M83646</link>
      <description>&lt;P&gt;SAS variable names cannot contain a dot (.) but we could use an underscore.&amp;nbsp; The following transposes for 5 visits using the DATA step.&amp;nbsp; This could be cleaned up and made more flexible, but it should do what you requested.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input SUBJ VISIT SITE1 SITE2 SITE3;
datalines;
1        1        3.5     4.5      2.5 
1        2        3.6     4.6      2.2
2        1        3.4     3.2      2.1
2        2        4.5     5.2      4.4
run;
data want(keep=subj site1_: site2_: site3_:);
   set have;
   by subj;
   array st1 {5} site1_1 - site1_5;
   array st2 {5} site2_1 - site2_5;
   array st3 {5} site3_1 - site3_5;
   retain site1: site2: site3: .;

   if first.subj then call missing(of st1{*} st2{*} st3{*});

   st1{visit} = site1;
   st2{visit} = site2;
   st3{visit} = site3;

   if last.subj then output want;
   run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 06 May 2017 23:57:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transposing-multiple-variables-from-multiple-time-points/m-p/356665#M83646</guid>
      <dc:creator>ArtC</dc:creator>
      <dc:date>2017-05-06T23:57:28Z</dc:date>
    </item>
    <item>
      <title>Re: Transposing multiple variables from multiple time points.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transposing-multiple-variables-from-multiple-time-points/m-p/356668#M83648</link>
      <description>&lt;P&gt;For your arrays are you more likely to do your analysis by site or time period? Which ever one is more common should be the first prefix in your variable. SAS can use prefixes to reference a variable list, which is why you'd want to factor this into your decision making.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 07 May 2017 00:30:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transposing-multiple-variables-from-multiple-time-points/m-p/356668#M83648</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-05-07T00:30:49Z</dc:date>
    </item>
    <item>
      <title>Re: Transposing multiple variables from multiple time points.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transposing-multiple-variables-from-multiple-time-points/m-p/356681#M83650</link>
      <description>&lt;P&gt;The simplest way is using IDGROUP.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or for big table, could try MERGE skill.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/resources/papers/proceedings15/2785-2015.pdf" target="_blank"&gt;http://support.sas.com/resources/papers/proceedings15/2785-2015.pdf&lt;/A&gt;&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 SUBJ VISIT SITE1 SITE2 SITE3 ;
  cards;
1        1        3.5     4.5      2.5 
1        2        3.6     4.6      2.2
2        1        3.4     3.2      2.1
2        2        4.5     5.2      4.4  
;
proc sql noprint;
select max(visit) into : max from have;
quit;


proc summary data=have ;
by subj;
output out=want idgroup(out[&amp;amp;max] (SITE1 SITE2 SITE3)=);
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 07 May 2017 02:58:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transposing-multiple-variables-from-multiple-time-points/m-p/356681#M83650</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-05-07T02:58:57Z</dc:date>
    </item>
    <item>
      <title>Re: Transposing multiple variables from multiple time points.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transposing-multiple-variables-from-multiple-time-points/m-p/356724#M83672</link>
      <description>&lt;P&gt;This works exactly as I was looking for. &amp;nbsp;I was used to doing this in another program but "transpose" function wasn't working for me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks.&lt;/P&gt;</description>
      <pubDate>Sun, 07 May 2017 17:58:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transposing-multiple-variables-from-multiple-time-points/m-p/356724#M83672</guid>
      <dc:creator>Jbhammon</dc:creator>
      <dc:date>2017-05-07T17:58:52Z</dc:date>
    </item>
  </channel>
</rss>

