<?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: Need assistance in restructuring data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Need-assistance-in-restructuring-data/m-p/346154#M79771</link>
    <description>&lt;P&gt;Yes, one comment variable for all the complaints in a single row. Thanks for quick response, I will try this proc and update the thread.&lt;/P&gt;</description>
    <pubDate>Fri, 31 Mar 2017 14:17:11 GMT</pubDate>
    <dc:creator>Bhuvaneswari</dc:creator>
    <dc:date>2017-03-31T14:17:11Z</dc:date>
    <item>
      <title>Need assistance in restructuring data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-assistance-in-restructuring-data/m-p/346150#M79769</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm looking for help in restructing data in the format specified in Data.PNG to the format specified in Anticipated output.PNG&lt;BR /&gt;Basically I just need one unique id per record. Kindly help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Bhuvana&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/13650iC9A96772E20091E8/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="Anticipated output.PNG" title="Anticipated output.PNG" /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/13651i6307044592F0748B/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="Data.PNG" title="Data.PNG" /&gt;</description>
      <pubDate>Fri, 31 Mar 2017 14:09:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-assistance-in-restructuring-data/m-p/346150#M79769</guid>
      <dc:creator>Bhuvaneswari</dc:creator>
      <dc:date>2017-03-31T14:09:06Z</dc:date>
    </item>
    <item>
      <title>Re: Need assistance in restructuring data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-assistance-in-restructuring-data/m-p/346152#M79770</link>
      <description>&lt;P&gt;Do you only want one comment variable or one for each complaint? Regardless, all you need to use is proc transpose.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 31 Mar 2017 14:14:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-assistance-in-restructuring-data/m-p/346152#M79770</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-03-31T14:14:02Z</dc:date>
    </item>
    <item>
      <title>Re: Need assistance in restructuring data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-assistance-in-restructuring-data/m-p/346154#M79771</link>
      <description>&lt;P&gt;Yes, one comment variable for all the complaints in a single row. Thanks for quick response, I will try this proc and update the thread.&lt;/P&gt;</description>
      <pubDate>Fri, 31 Mar 2017 14:17:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-assistance-in-restructuring-data/m-p/346154#M79771</guid>
      <dc:creator>Bhuvaneswari</dc:creator>
      <dc:date>2017-03-31T14:17:11Z</dc:date>
    </item>
    <item>
      <title>Re: Need assistance in restructuring data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-assistance-in-restructuring-data/m-p/346161#M79775</link>
      <description>&lt;P&gt;Actually, given your data, it would take a data step (to create a counter field), proc sort, and then at least two uses of proc transpose, one to make the file long, then another to make the file wide.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;An alternative that does it all in one step is to use a macro that a number of us wrote some years ago. You can download the macro (it's free) 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;If you download and run that macro, the following will accomplish what you want:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%transpose(data=have, out=want, by=id name country,
           var=complaints_description complaint_id,
           copy=comments, sort=yes, guessingrows=1000)
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 31 Mar 2017 14:41:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-assistance-in-restructuring-data/m-p/346161#M79775</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-03-31T14:41:11Z</dc:date>
    </item>
    <item>
      <title>Re: Need assistance in restructuring data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-assistance-in-restructuring-data/m-p/346182#M79785</link>
      <description>Without data I hesitate to comment. However a single datastep with two arrays might work? May need to presort? Process four records and output 1?</description>
      <pubDate>Fri, 31 Mar 2017 15:30:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-assistance-in-restructuring-data/m-p/346182#M79785</guid>
      <dc:creator>rogerjdeangelis</dc:creator>
      <dc:date>2017-03-31T15:30:16Z</dc:date>
    </item>
    <item>
      <title>Re: Need assistance in restructuring data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-assistance-in-restructuring-data/m-p/346189#M79790</link>
      <description>&lt;P&gt;A single DATA step with two arrays would work, but requires knowing a little more about the data. &amp;nbsp;Is there a maximum of four entries per customer? &amp;nbsp;That maximum tells you how many elements to set up in each array. &amp;nbsp;Other than that, though, the DATA step is pretty straightforward array processing:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Use sorted data with a BY statement&lt;/LI&gt;
&lt;LI&gt;Set all array elements to missing when beginning a new customer's data&lt;/LI&gt;
&lt;LI&gt;Create a counter that tracks which observation number are on working with for the current customer&lt;/LI&gt;
&lt;LI&gt;Populate array elements (remember to retain them)&lt;/LI&gt;
&lt;LI&gt;Output when reaching the last observation per customer&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Fri, 31 Mar 2017 15:46:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-assistance-in-restructuring-data/m-p/346189#M79790</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-03-31T15:46:49Z</dc:date>
    </item>
    <item>
      <title>Re: Need assistance in restructuring data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-assistance-in-restructuring-data/m-p/346195#M79792</link>
      <description>&lt;P&gt;Thanks for the reply. I was able to get this issue sorted by using the transpose macro given above but would like to try other coding alternatives. &amp;nbsp;To answer your question, there are varying number of entries per customers. In such cases, should we give the maximum value as array dimension?&amp;nbsp;Appreciate the help.&lt;/P&gt;</description>
      <pubDate>Fri, 31 Mar 2017 16:03:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-assistance-in-restructuring-data/m-p/346195#M79792</guid>
      <dc:creator>Bhuvaneswari</dc:creator>
      <dc:date>2017-03-31T16:03:09Z</dc:date>
    </item>
    <item>
      <title>Re: Need assistance in restructuring data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-assistance-in-restructuring-data/m-p/346196#M79793</link>
      <description>&lt;P&gt;Thanks a lot for coming to the rescue :). Have a good weekend!&lt;/P&gt;</description>
      <pubDate>Fri, 31 Mar 2017 16:04:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-assistance-in-restructuring-data/m-p/346196#M79793</guid>
      <dc:creator>Bhuvaneswari</dc:creator>
      <dc:date>2017-03-31T16:04:03Z</dc:date>
    </item>
    <item>
      <title>Re: Need assistance in restructuring data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-assistance-in-restructuring-data/m-p/346204#M79797</link>
      <description>&lt;P&gt;Yes, to build a datastep solution that uses arrays:&lt;/P&gt;
&lt;P&gt;1.First, you have to insure that your data is in the proper order (i.e., include a proc sort if necessary)&lt;/P&gt;
&lt;P&gt;2.Know the maximum number of replications&lt;/P&gt;
&lt;P&gt;3.Create (and retain) arrays for each of the variables you want to transpose (insuring that you have them correctly set to accept character/numeric data)&lt;/P&gt;
&lt;P&gt;4,Use by processing to control a counter that indicates replications within an id (i.e., when first.id)&lt;/P&gt;
&lt;P&gt;5.Use by processing to know when to output the record (i.e., last.id)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That's why I prefer the transpose macro. the guessingrows parameter lets you decide how many records need to be reviewed in order to determine the maximum arrays needed, the sort parameter does the sort for you and, if you are transposing both character and numeric data, it keeps their original formats (which proc transpose doesn't do).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 31 Mar 2017 16:17:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-assistance-in-restructuring-data/m-p/346204#M79797</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-03-31T16:17:50Z</dc:date>
    </item>
    <item>
      <title>Re: Need assistance in restructuring data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-assistance-in-restructuring-data/m-p/346251#M79814</link>
      <description>&lt;P&gt;Absoutely!&amp;nbsp;&lt;/P&gt;&lt;P&gt;Transpose macro worked like magic. I think I'm gonna use it on several occasions in future. Appreciate your help!&lt;/P&gt;</description>
      <pubDate>Fri, 31 Mar 2017 17:36:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-assistance-in-restructuring-data/m-p/346251#M79814</guid>
      <dc:creator>Bhuvaneswari</dc:creator>
      <dc:date>2017-03-31T17:36:55Z</dc:date>
    </item>
  </channel>
</rss>

