<?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 first observation is variable name in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/first-observation-is-variable-name/m-p/511934#M15890</link>
    <description>&lt;P&gt;Currently, My data is like:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;D&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Name&lt;/TD&gt;&lt;TD&gt;Sex&lt;/TD&gt;&lt;TD&gt;Address&lt;/TD&gt;&lt;TD&gt;Phone&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Rachel&lt;/TD&gt;&lt;TD&gt;F&lt;/TD&gt;&lt;TD&gt;789 Mid County&lt;/TD&gt;&lt;TD&gt;111-111-1111&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My first observation is my variable name. therefore, I want my data to look like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Name&lt;/TD&gt;&lt;TD&gt;Sex&lt;/TD&gt;&lt;TD&gt;Address&lt;/TD&gt;&lt;TD&gt;Phone&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Rachel&lt;/TD&gt;&lt;TD&gt;F&lt;/TD&gt;&lt;TD&gt;789 Mid County&lt;/TD&gt;&lt;TD&gt;111-111-1111&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help!&lt;/P&gt;</description>
    <pubDate>Sat, 10 Nov 2018 16:37:29 GMT</pubDate>
    <dc:creator>pmpradhan</dc:creator>
    <dc:date>2018-11-10T16:37:29Z</dc:date>
    <item>
      <title>first observation is variable name</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/first-observation-is-variable-name/m-p/511934#M15890</link>
      <description>&lt;P&gt;Currently, My data is like:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;D&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Name&lt;/TD&gt;&lt;TD&gt;Sex&lt;/TD&gt;&lt;TD&gt;Address&lt;/TD&gt;&lt;TD&gt;Phone&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Rachel&lt;/TD&gt;&lt;TD&gt;F&lt;/TD&gt;&lt;TD&gt;789 Mid County&lt;/TD&gt;&lt;TD&gt;111-111-1111&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My first observation is my variable name. therefore, I want my data to look like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Name&lt;/TD&gt;&lt;TD&gt;Sex&lt;/TD&gt;&lt;TD&gt;Address&lt;/TD&gt;&lt;TD&gt;Phone&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Rachel&lt;/TD&gt;&lt;TD&gt;F&lt;/TD&gt;&lt;TD&gt;789 Mid County&lt;/TD&gt;&lt;TD&gt;111-111-1111&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help!&lt;/P&gt;</description>
      <pubDate>Sat, 10 Nov 2018 16:37:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/first-observation-is-variable-name/m-p/511934#M15890</guid>
      <dc:creator>pmpradhan</dc:creator>
      <dc:date>2018-11-10T16:37:29Z</dc:date>
    </item>
    <item>
      <title>Re: first observation is variable name</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/first-observation-is-variable-name/m-p/511935#M15891</link>
      <description>&lt;P&gt;Is current sas dataset?&lt;/P&gt;
&lt;P&gt;excel or some other like csv?&lt;/P&gt;</description>
      <pubDate>Sat, 10 Nov 2018 17:02:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/first-observation-is-variable-name/m-p/511935#M15891</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-11-10T17:02:29Z</dc:date>
    </item>
    <item>
      <title>Re: first observation is variable name</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/first-observation-is-variable-name/m-p/511937#M15892</link>
      <description>&lt;P&gt;Yes it is SAS dataset.&lt;/P&gt;</description>
      <pubDate>Sat, 10 Nov 2018 17:07:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/first-observation-is-variable-name/m-p/511937#M15892</guid>
      <dc:creator>pmpradhan</dc:creator>
      <dc:date>2018-11-10T17:07:40Z</dc:date>
    </item>
    <item>
      <title>Re: first observation is variable name</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/first-observation-is-variable-name/m-p/511939#M15893</link>
      <description>&lt;P&gt;Sorry to say that is a poor data table.&amp;nbsp; Looks like the solution should have been handled during the creating of the original table.&amp;nbsp; Why would anyone create a table in that manner in SAS.&lt;/P&gt;</description>
      <pubDate>Sat, 10 Nov 2018 17:15:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/first-observation-is-variable-name/m-p/511939#M15893</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2018-11-10T17:15:13Z</dc:date>
    </item>
    <item>
      <title>Re: first observation is variable name</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/first-observation-is-variable-name/m-p/511940#M15894</link>
      <description>Agree, One of the simple way, I found is renaming all vars then deleting first observation. I was hoping to see if others find a different way.</description>
      <pubDate>Sat, 10 Nov 2018 17:24:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/first-observation-is-variable-name/m-p/511940#M15894</guid>
      <dc:creator>pmpradhan</dc:creator>
      <dc:date>2018-11-10T17:24:02Z</dc:date>
    </item>
    <item>
      <title>Re: first observation is variable name</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/first-observation-is-variable-name/m-p/511941#M15895</link>
      <description>&lt;P&gt;Well done, i think your approach is pretty sound!&lt;/P&gt;</description>
      <pubDate>Sat, 10 Nov 2018 17:27:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/first-observation-is-variable-name/m-p/511941#M15895</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-11-10T17:27:32Z</dc:date>
    </item>
    <item>
      <title>Re: first observation is variable name</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/first-observation-is-variable-name/m-p/511942#M15896</link>
      <description>&lt;P&gt;So you have a sas dataset with (1) var names of A, B, C, ..., (2) the intended var names are actually the values of A, B, C, ... in the first row.&amp;nbsp; Looks like it was once a spreadsheet.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is the spreadsheet still available?&amp;nbsp; If so, use proc import.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Nov 2018 17:33:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/first-observation-is-variable-name/m-p/511942#M15896</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-11-10T17:33:02Z</dc:date>
    </item>
    <item>
      <title>Re: first observation is variable name</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/first-observation-is-variable-name/m-p/511943#M15897</link>
      <description>Unfortunately not.</description>
      <pubDate>Sat, 10 Nov 2018 17:33:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/first-observation-is-variable-name/m-p/511943#M15897</guid>
      <dc:creator>pmpradhan</dc:creator>
      <dc:date>2018-11-10T17:33:45Z</dc:date>
    </item>
    <item>
      <title>Re: first observation is variable name</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/first-observation-is-variable-name/m-p/511944#M15898</link>
      <description>&lt;OL&gt;
&lt;LI&gt;Establish a temporary file for holding renames&lt;/LI&gt;
&lt;LI&gt;Read the first obs&lt;/LI&gt;
&lt;LI&gt;Write to #1 above using a "put (_all_) (=)" statement to write&amp;nbsp;&amp;nbsp; a set of name=value pairs, where the names will be A, B, C, D and the values will be the content in the first obs.&lt;/LI&gt;
&lt;LI&gt;Run a second data step with (firstobs=2),&amp;nbsp; and include the renames written above&lt;/LI&gt;
&lt;/OL&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input A $6. +1 B $3. +1 C $14.  +1  D $12.;
datalines;
Name   Sex Address        Phone 
Rachel F   789 Mid County 111-111-1111 
run;

filename renames temp ;

data _null_;
  set have (obs=1);
  file renames;
  put 'rename '
    / (_all_) (=)
	/ ';'
	;
run;

data want;
  set have (firstobs=2);
  %include renames ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 10 Nov 2018 17:43:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/first-observation-is-variable-name/m-p/511944#M15898</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-11-10T17:43:27Z</dc:date>
    </item>
    <item>
      <title>Re: first observation is variable name</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/first-observation-is-variable-name/m-p/666964#M19401</link>
      <description>&lt;P&gt;Outdated reply but may help someone in future&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*----------------------------------------*/&lt;BR /&gt;data test;&lt;BR /&gt;infile datalines;&lt;BR /&gt;input A : $10. B : $3. C &amp;amp; $20. D : $20.;&lt;BR /&gt;datalines;&lt;BR /&gt;Name Sex Address Phone&lt;BR /&gt;Rachel F 789 Mid County 111-111-1111&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc transpose data=test out=testt;&lt;BR /&gt;var A B C D;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc transpose data=testt out=testtt(drop=_:);&lt;BR /&gt;var col2;&lt;BR /&gt;id col1;&lt;BR /&gt;run;&lt;BR /&gt;/*----------------------------------------*/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 04 Jul 2020 20:44:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/first-observation-is-variable-name/m-p/666964#M19401</guid>
      <dc:creator>tocilj</dc:creator>
      <dc:date>2020-07-04T20:44:18Z</dc:date>
    </item>
    <item>
      <title>Re: first observation is variable name</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/first-observation-is-variable-name/m-p/667228#M19408</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/322220"&gt;@tocilj&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The double proc transpose is nice in that it has a simple structure, and it uses a pre-packaged sas routine.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But it may not scale well.&amp;nbsp; Transposing 1,000,000 observations will create a dataset with 1,000,000 variables in the intermediate data set TEST1.&amp;nbsp; The entire dataset would have to be processed two times, which can begin to use significant resources.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jul 2020 16:21:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/first-observation-is-variable-name/m-p/667228#M19408</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2020-07-06T16:21:18Z</dc:date>
    </item>
  </channel>
</rss>

