<?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 help with transposing data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/help-with-transposing-data/m-p/24397#M4115</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi. Art.T&lt;/P&gt;&lt;P&gt;But If one person has more than two address?&lt;/P&gt;&lt;P&gt;and the number of address is vary?&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, 05 Jul 2011 03:07:42 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2011-07-05T03:07:42Z</dc:date>
    <item>
      <title>help with transposing data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/help-with-transposing-data/m-p/24392#M4110</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;Sorry if this was discussed but I couldn't find my particular problem:&lt;/P&gt;&lt;P&gt;I have a file that contains several thousand cases and only one variable ( I called it 'dummy') like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Name Person 1&lt;/P&gt;&lt;P&gt;Address Person 1&lt;/P&gt;&lt;P&gt;Address 2 Person 1&lt;/P&gt;&lt;P&gt;Name Person 2&lt;/P&gt;&lt;P&gt;Address Person 2&lt;/P&gt;&lt;P&gt;Address 2 Person 2&lt;/P&gt;&lt;P&gt;Name Person 3&lt;/P&gt;&lt;P&gt;Address Person 3&lt;/P&gt;&lt;P&gt;Address 2 Person 3&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and I would like a 'normal' data set with the variables Name, Address1 and Address2.&lt;/P&gt;&lt;P&gt;I am very grateful for any help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Andreas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jun 2011 20:52:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/help-with-transposing-data/m-p/24392#M4110</guid>
      <dc:creator>areich</dc:creator>
      <dc:date>2011-06-30T20:52:49Z</dc:date>
    </item>
    <item>
      <title>help with transposing data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/help-with-transposing-data/m-p/24393#M4111</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; I think you can use Data step to deal with it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data dummy; &lt;/P&gt;&lt;P&gt;length name address1 address2 $ 20;&lt;/P&gt;&lt;P&gt;input name $ address1 $ address2 $ @@;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;Name_Person_1&lt;/P&gt;&lt;P&gt;Address_Person_1&lt;/P&gt;&lt;P&gt;Address 2_Person_1&lt;/P&gt;&lt;P&gt;Name_Person_2&lt;/P&gt;&lt;P&gt;Address_Person_2&lt;/P&gt;&lt;P&gt;Address_2 Person_2&lt;/P&gt;&lt;P&gt;Name_Person_3&lt;/P&gt;&lt;P&gt;Address_Person_3&lt;/P&gt;&lt;P&gt;Address_2_Person_3&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jun 2011 21:04:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/help-with-transposing-data/m-p/24393#M4111</guid>
      <dc:creator>QLi</dc:creator>
      <dc:date>2011-06-30T21:04:58Z</dc:date>
    </item>
    <item>
      <title>help with transposing data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/help-with-transposing-data/m-p/24394#M4112</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is some complicated.&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 temp;
 input dummy $50.;
cards;
Name Person1
Address Person1
Address2 Person1
Name Person2
Address Person2
Address2 Person2
Name Person3
Address Person3
Address2 Person3
;
run;
data temp;
 set temp;
 if dummy eq: 'Name' then count+1;
run;
data _null_;
 set temp end=last;
 by count notsorted;
 if _n_ eq 1 then call execute('data want;');
 if first.count then n=0;
 if dummy ne: 'Name' then&amp;nbsp; n+1;
 if dummy eq: 'Name' then call execute('name="'||dummy||'";');
&amp;nbsp; else&amp;nbsp; call execute('address'||strip(n)||'="'||dummy||'";');
 if last.count then call execute('output;');
 if last then call execute('run;');
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;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Jul 2011 03:52:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/help-with-transposing-data/m-p/24394#M4112</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-07-01T03:52:53Z</dc:date>
    </item>
    <item>
      <title>help with transposing data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/help-with-transposing-data/m-p/24395#M4113</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Provided your bput is always spread over three lines (name, address1, address2) then this is how it could be done:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data addresses;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; input name $ / address1 $ / address2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The example is far from complete but; it just illustrates the use of the slash as a way to move the input to the next line. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck,&lt;/P&gt;&lt;P&gt;- Jan.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Jul 2011 16:24:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/help-with-transposing-data/m-p/24395#M4113</guid>
      <dc:creator>jklaverstijn</dc:creator>
      <dc:date>2011-07-04T16:24:56Z</dc:date>
    </item>
    <item>
      <title>help with transposing data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/help-with-transposing-data/m-p/24396#M4114</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You might be looking for something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want (drop=dummy);&lt;/P&gt;&lt;P&gt;&amp;nbsp; length Name Address Address2 $30;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; retain Name Address;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if mod(_n_,3) eq 1 then Name=dummy;&lt;/P&gt;&lt;P&gt;&amp;nbsp; else if mod(_n_,3) eq 2 then Address=dummy;&lt;/P&gt;&lt;P&gt;&amp;nbsp; else do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Address2=dummy;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HTH,&lt;/P&gt;&lt;P&gt;Art&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Jul 2011 17:51:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/help-with-transposing-data/m-p/24396#M4114</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-07-04T17:51:07Z</dc:date>
    </item>
    <item>
      <title>help with transposing data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/help-with-transposing-data/m-p/24397#M4115</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi. Art.T&lt;/P&gt;&lt;P&gt;But If one person has more than two address?&lt;/P&gt;&lt;P&gt;and the number of address is vary?&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, 05 Jul 2011 03:07:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/help-with-transposing-data/m-p/24397#M4115</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-07-05T03:07:42Z</dc:date>
    </item>
    <item>
      <title>help with transposing data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/help-with-transposing-data/m-p/24398#M4116</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ksharp,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't think it is a question of how complex one could make the problem but, rather, what the OP was really trying to solve.&amp;nbsp; Only he or she can say whether what any of us propose actually can serve as a potential solution.&amp;nbsp; Given what little information was provided, I would (and will) wait until they write back before losing any sleep over potential complexities.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Art&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jul 2011 03:36:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/help-with-transposing-data/m-p/24398#M4116</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-07-05T03:36:20Z</dc:date>
    </item>
    <item>
      <title>help with transposing data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/help-with-transposing-data/m-p/24399#M4117</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK.:)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jul 2011 03:55:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/help-with-transposing-data/m-p/24399#M4117</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-07-05T03:55:44Z</dc:date>
    </item>
    <item>
      <title>help with transposing data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/help-with-transposing-data/m-p/24400#M4118</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks a lot all of you. Ksharp's example works fine (I have to find out why and how). The only small thing is that since the string 'Name' is not in my dummy variable, I end up with three variables called address1-address3 but I can rename variables. I had cleaned up the data before, removing phone and fax numbers (there were different numbers of them but luckily we don't need them at the moment).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have different data files in different exotic formats so this may help me in figuring them out myself, the principle is the same. Thanks again to all of you for your fast and helpful responses!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jul 2011 07:35:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/help-with-transposing-data/m-p/24400#M4118</guid>
      <dc:creator>areich</dc:creator>
      <dc:date>2011-07-05T07:35:01Z</dc:date>
    </item>
    <item>
      <title>Re: help with transposing data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/help-with-transposing-data/m-p/24401#M4119</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Now I feel stupid, I don't know if I only tried with the test data earlier but it doesn't work, since the data doesn't have the text 'Name' in it, I guess.&lt;/P&gt;&lt;P&gt;I need to create a 'count' variable that is 1 for the first 3 observations, 2 for the next 3 and so on, then the code would work. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hmm, I had an idea and the result looks ok, I will check.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jul 2011 16:32:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/help-with-transposing-data/m-p/24401#M4119</guid>
      <dc:creator>areich</dc:creator>
      <dc:date>2011-07-05T16:32:16Z</dc:date>
    </item>
    <item>
      <title>Re: help with transposing data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/help-with-transposing-data/m-p/24402#M4120</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not elegant (I needed two steps to create the ID) but it works:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data tmp2;&lt;/P&gt;&lt;P&gt; set tmp1;&lt;/P&gt;&lt;P&gt; count= MOD(_N_,3);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data tmp3;&lt;/P&gt;&lt;P&gt; set tmp2;&lt;/P&gt;&lt;P&gt; if count=0 then count=3;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want (drop=dummy);&lt;/P&gt;&lt;P&gt;&amp;nbsp; length Name Address Address2 $30;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set tmp3;&lt;/P&gt;&lt;P&gt;&amp;nbsp; retain Name Address Address2;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if count=1 then Name=dummy;&lt;/P&gt;&lt;P&gt;&amp;nbsp; else if count=2 then Address=dummy;&lt;/P&gt;&lt;P&gt;&amp;nbsp; else do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Address2=dummy;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;At first it didn't work but it just showed me some data I hadn't cleaned up.&lt;/P&gt;&lt;P&gt;Thanks all of you!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jul 2011 17:08:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/help-with-transposing-data/m-p/24402#M4120</guid>
      <dc:creator>areich</dc:creator>
      <dc:date>2011-07-05T17:08:34Z</dc:date>
    </item>
    <item>
      <title>Re: help with transposing data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/help-with-transposing-data/m-p/24403#M4121</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;FWIW, that is exactly what my suggested code did, but with only one datastep and only requiring one pass through the data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Art&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jul 2011 17:27:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/help-with-transposing-data/m-p/24403#M4121</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-07-05T17:27:49Z</dc:date>
    </item>
    <item>
      <title>Re: help with transposing data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/help-with-transposing-data/m-p/24404#M4122</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, thank you, you can see I used your code. It didn't work at first, probably because 'address2' was not retained.&lt;/P&gt;&lt;P&gt;It is easy and I can understand how it works. I had actually created the count variable myself (but as I saw afterwards using the same function you used) and at the time I thought I needed it to be 1, 2, 3 but of course 1, 2, 0 works just as well. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I see now that I could have just used your code after adding 'address2' after retain. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jul 2011 17:39:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/help-with-transposing-data/m-p/24404#M4122</guid>
      <dc:creator>areich</dc:creator>
      <dc:date>2011-07-05T17:39:12Z</dc:date>
    </item>
    <item>
      <title>Re: help with transposing data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/help-with-transposing-data/m-p/24405#M4123</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You don't have to retain Address2 as the record is being output as soon as you assign Address2.&amp;nbsp; Variables only have to be retained if you need to keep them across iterations.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Art&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jul 2011 17:44:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/help-with-transposing-data/m-p/24405#M4123</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-07-05T17:44:06Z</dc:date>
    </item>
    <item>
      <title>Re: help with transposing data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/help-with-transposing-data/m-p/24406#M4124</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You're right again. My problems with running your code were caused entirely by the erroneous cases that were still in my data set but I didn't know it at the time.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jul 2011 18:23:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/help-with-transposing-data/m-p/24406#M4124</guid>
      <dc:creator>areich</dc:creator>
      <dc:date>2011-07-05T18:23:51Z</dc:date>
    </item>
  </channel>
</rss>

