<?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: How to change a very unique and long horizontal data to vertical. in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-change-a-very-unique-and-long-horizontal-data-to-vertical/m-p/582721#M17839</link>
    <description>&lt;P&gt;I have data like this&amp;nbsp;&lt;/P&gt;&lt;P&gt;data ds;&lt;/P&gt;&lt;P&gt;x=123456789;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I want output like this&lt;/P&gt;&lt;P&gt;&amp;nbsp;output;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; x&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; 3&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; 4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; 5&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; 6&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; 7&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; 8&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; 9&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;how to do.....????&lt;/P&gt;</description>
    <pubDate>Wed, 21 Aug 2019 11:04:46 GMT</pubDate>
    <dc:creator>Ayaan</dc:creator>
    <dc:date>2019-08-21T11:04:46Z</dc:date>
    <item>
      <title>How to change a very unique and long horizontal data to vertical.</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-change-a-very-unique-and-long-horizontal-data-to-vertical/m-p/398313#M12094</link>
      <description>&lt;P&gt;Hello everyone,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am working on cleaning up a dataset that seems to be very complicated and I have been unable to convert it into a way that I want it to be. Please see the attached file. Each company (referred to as Firm A, B, C, ... ) has a few variables (Date, Var1, Var2, and Var 3) and each variable has up to 2,000 observations. There is a column of 'blank' between the Var3 column of Firm_i and the date variable column of Firm_(i+1). In a spreadsheet, there are about 800 Firms. That is, each firm has 4 variables and one blank column so there are approximately 4,000 columns in the spreadsheet. I would like to convert this into a dataset that is easy for me to analyze on SAS. (Please see the 'after' example.)&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any way I can use SAS to manipulate this kind of dataset? My first thoughts were to use Proc Transpose but it did not work the way I wanted it to be. If anyone could share any ideas regarding the solution to this problem, I would be very grateful.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much for your time.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 23 Sep 2017 20:52:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-change-a-very-unique-and-long-horizontal-data-to-vertical/m-p/398313#M12094</guid>
      <dc:creator>kishiyo</dc:creator>
      <dc:date>2017-09-23T20:52:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to change a very unique and long horizontal data to vertical.</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-change-a-very-unique-and-long-horizontal-data-to-vertical/m-p/398316#M12095</link>
      <description>&lt;P&gt;Do you have to read the spreadsheet? &amp;nbsp;Can you save the data to a CSV file instead?&lt;/P&gt;
&lt;P&gt;If so then something like this should work, assuming that the structure is as predictable as you showed.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data firms (keep=firmno firm)
     values(keep=firmno date var1-var3 )
;
  infile 'myfile.csv' dsd truncover lrecl=1000000 ;
  length firmno 8 firm $20 date var1-var3 8 dummy $1 ;
  informat date mmddyy. ;
  format date yymmdd10. ;
  if _n_=1 then do;
    do firmno=1 by 1 until (firm=' ');
      input firm 4*dummy @;
      if firm ne ' ' then output firms ;
    end;
   input / ;
   nfirms=firmno;
   retain nfirms;
  end;
  do firmno = 1 to nfirms ;
    input date var-var3 dummy @;
    output values;
  end;
  input;
run;

proc sql ;
  create table want as 
    select * from firms a, values b
    where a.firmno = b.firmno
   order by b.firmno,b.date
  ;
quit;
  
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 23 Sep 2017 21:16:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-change-a-very-unique-and-long-horizontal-data-to-vertical/m-p/398316#M12095</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-09-23T21:16:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to change a very unique and long horizontal data to vertical.</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-change-a-very-unique-and-long-horizontal-data-to-vertical/m-p/398321#M12096</link>
      <description>&lt;P&gt;Dear Tom,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It worked perfectly and now the dataset looks exactly what I wanted.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much for your help!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kishiyo.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 23 Sep 2017 22:40:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-change-a-very-unique-and-long-horizontal-data-to-vertical/m-p/398321#M12096</guid>
      <dc:creator>kishiyo</dc:creator>
      <dc:date>2017-09-23T22:40:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to change a very unique and long horizontal data to vertical.</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-change-a-very-unique-and-long-horizontal-data-to-vertical/m-p/582721#M17839</link>
      <description>&lt;P&gt;I have data like this&amp;nbsp;&lt;/P&gt;&lt;P&gt;data ds;&lt;/P&gt;&lt;P&gt;x=123456789;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I want output like this&lt;/P&gt;&lt;P&gt;&amp;nbsp;output;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; x&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; 3&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; 4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; 5&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; 6&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; 7&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; 8&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; 9&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;how to do.....????&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2019 11:04:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-change-a-very-unique-and-long-horizontal-data-to-vertical/m-p/582721#M17839</guid>
      <dc:creator>Ayaan</dc:creator>
      <dc:date>2019-08-21T11:04:46Z</dc:date>
    </item>
  </channel>
</rss>

