<?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: Transform tables to match example in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Transform-tables-to-match-example/m-p/161834#M31443</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I "branched" this into a new topic.&lt;/P&gt;&lt;P&gt;Your data looks simple enough to use PROC TRANSPOSE.&lt;/P&gt;&lt;P&gt;Your BY variables should be FIRM and COUNTRY.&lt;/P&gt;&lt;P&gt;Your ID variable is VARIABLE.&lt;/P&gt;&lt;P&gt;And you can use _: to tell it to transform all of the _ variables.&amp;nbsp; In the output data set these variable names will be in the _NAME_ variable and the _LABEL_ value seems to have the actual YEAR value ('2005' for example is the label for the _005 variable).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BUT your FIRM/COUNTRY/VARIABLE combinations are NOT distinct.&amp;nbsp; For example FIRM='SUZA'.&lt;/P&gt;&lt;P&gt;Perhaps if you add another variable?&lt;/P&gt;&lt;P&gt;It seems to me that when VARIABLE='ROA' it is starting a new block of values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note that the values of VARIABLE could also be cleaned up to make them more consistent with each other and with your sample target table.&lt;/P&gt;&lt;P&gt;In Particular I found that some of the value have leading spaces.&lt;/P&gt;&lt;P&gt;So this little program let me at least transpose the data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data fix_emerging;&lt;/P&gt;&lt;P&gt; set tmp3.emerging;&lt;/P&gt;&lt;P&gt; by firm country notsorted;&lt;/P&gt;&lt;P&gt; variable=LEFT(UPCASE(VARIABLE));&lt;/P&gt;&lt;P&gt; block+(first.country or variable='ROA');&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;proc transpose data=fix_emerging out=want (rename=(_label_=year));&lt;/P&gt;&lt;P&gt;&amp;nbsp; by block firm country ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; id variable ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; var&amp;nbsp; _: ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 24 Dec 2014 17:41:48 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2014-12-24T17:41:48Z</dc:date>
    <item>
      <title>Transform tables to match example</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transform-tables-to-match-example/m-p/161833#M31442</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Tom, I know this is not right place to post my query. But i need your help if you please. I am attaching files that i need to transform same like the sample file present in the attachment. Can you please help me with the procedure. I shall be thankful to you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Dec 2014 16:41:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transform-tables-to-match-example/m-p/161833#M31442</guid>
      <dc:creator>Jahanzaib</dc:creator>
      <dc:date>2014-12-24T16:41:24Z</dc:date>
    </item>
    <item>
      <title>Re: Transform tables to match example</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transform-tables-to-match-example/m-p/161834#M31443</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I "branched" this into a new topic.&lt;/P&gt;&lt;P&gt;Your data looks simple enough to use PROC TRANSPOSE.&lt;/P&gt;&lt;P&gt;Your BY variables should be FIRM and COUNTRY.&lt;/P&gt;&lt;P&gt;Your ID variable is VARIABLE.&lt;/P&gt;&lt;P&gt;And you can use _: to tell it to transform all of the _ variables.&amp;nbsp; In the output data set these variable names will be in the _NAME_ variable and the _LABEL_ value seems to have the actual YEAR value ('2005' for example is the label for the _005 variable).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BUT your FIRM/COUNTRY/VARIABLE combinations are NOT distinct.&amp;nbsp; For example FIRM='SUZA'.&lt;/P&gt;&lt;P&gt;Perhaps if you add another variable?&lt;/P&gt;&lt;P&gt;It seems to me that when VARIABLE='ROA' it is starting a new block of values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note that the values of VARIABLE could also be cleaned up to make them more consistent with each other and with your sample target table.&lt;/P&gt;&lt;P&gt;In Particular I found that some of the value have leading spaces.&lt;/P&gt;&lt;P&gt;So this little program let me at least transpose the data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data fix_emerging;&lt;/P&gt;&lt;P&gt; set tmp3.emerging;&lt;/P&gt;&lt;P&gt; by firm country notsorted;&lt;/P&gt;&lt;P&gt; variable=LEFT(UPCASE(VARIABLE));&lt;/P&gt;&lt;P&gt; block+(first.country or variable='ROA');&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;proc transpose data=fix_emerging out=want (rename=(_label_=year));&lt;/P&gt;&lt;P&gt;&amp;nbsp; by block firm country ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; id variable ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; var&amp;nbsp; _: ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Dec 2014 17:41:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transform-tables-to-match-example/m-p/161834#M31443</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-12-24T17:41:48Z</dc:date>
    </item>
    <item>
      <title>Re: Transform tables to match example</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transform-tables-to-match-example/m-p/161835#M31444</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;many many Thanks dear TOM it is done. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Dec 2014 14:28:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transform-tables-to-match-example/m-p/161835#M31444</guid>
      <dc:creator>Jahanzaib</dc:creator>
      <dc:date>2014-12-25T14:28:06Z</dc:date>
    </item>
  </channel>
</rss>

