<?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: Make row one the header in datastep in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Make-row-one-the-header-in-datastep/m-p/744174#M233099</link>
    <description>Are you reading this data from a text file or from cards/datalines?</description>
    <pubDate>Thu, 27 May 2021 14:54:17 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2021-05-27T14:54:17Z</dc:date>
    <item>
      <title>Make row one the header in datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Make-row-one-the-header-in-datastep/m-p/744170#M233097</link>
      <description>&lt;PRE&gt;data have;
length
  a $25
  b $4
  c $8
  d $8
;
input a b c d ;
datalines;
dept month_ count_ status 
Acct JAN20 1 0 
Eng FEB20 1 1  
Sales FEB20 1 1   
 
;
run;&lt;/PRE&gt;
&lt;TABLE width="320"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="64"&gt;a&lt;/TD&gt;
&lt;TD width="64"&gt;b&lt;/TD&gt;
&lt;TD width="64"&gt;c&lt;/TD&gt;
&lt;TD width="64"&gt;d&lt;/TD&gt;
&lt;TD width="64"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;dept&lt;/TD&gt;
&lt;TD&gt;mont&lt;/TD&gt;
&lt;TD&gt;count_&lt;/TD&gt;
&lt;TD&gt;status&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Acct&lt;/TD&gt;
&lt;TD&gt;JAN2&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&g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/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Sales&lt;/TD&gt;
&lt;TD&gt;FEB2&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;I tried&lt;/P&gt;
&lt;P&gt;data have2 (firstobs=2);&lt;BR /&gt;set have;&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 May 2021 14:49:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Make-row-one-the-header-in-datastep/m-p/744170#M233097</guid>
      <dc:creator>Q1983</dc:creator>
      <dc:date>2021-05-27T14:49:00Z</dc:date>
    </item>
    <item>
      <title>Re: Make row one the header in datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Make-row-one-the-header-in-datastep/m-p/744172#M233098</link>
      <description>&lt;P&gt;Good start, although I would put the FIRSTOBS= dataset option on the INPUT dataset and not the OUTPUT dataset.&lt;/P&gt;
&lt;P&gt;You also want to use the first row to RENAME the variables.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is an easy method using PROC TRANSPOSE.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=have(obs=1) out=names ;
  var _all_;
run;

proc sql noprint;
  select catx('=',nliteral(_name_),nliteral(col1))
    into :renames separated by ' '
  from names
  where upcase(_name_) ne upcase(col1)
 ;
quit;

data want;
   set have (firstobs=2);
   rename &amp;amp;renames;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 May 2021 15:22:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Make-row-one-the-header-in-datastep/m-p/744172#M233098</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-05-27T15:22:01Z</dc:date>
    </item>
    <item>
      <title>Re: Make row one the header in datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Make-row-one-the-header-in-datastep/m-p/744174#M233099</link>
      <description>Are you reading this data from a text file or from cards/datalines?</description>
      <pubDate>Thu, 27 May 2021 14:54:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Make-row-one-the-header-in-datastep/m-p/744174#M233099</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-05-27T14:54:17Z</dc:date>
    </item>
    <item>
      <title>Re: Make row one the header in datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Make-row-one-the-header-in-datastep/m-p/744179#M233103</link>
      <description>&lt;P&gt;If you also want to change the variables that look like numbers into numeric variables then you might be able to let PROC IMPORT help you.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename csv temp;
data _null_;
  set have ;
  file csv dsd ;
  put (_all_) (+0);
run;
proc import datafile=csv dbms=csv out=want replace ;
  guessingrows=max;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 May 2021 14:57:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Make-row-one-the-header-in-datastep/m-p/744179#M233103</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-05-27T14:57:38Z</dc:date>
    </item>
    <item>
      <title>Re: Make row one the header in datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Make-row-one-the-header-in-datastep/m-p/744186#M233109</link>
      <description>When I run the last piece of code I get an error in the set data line.   Should that be something else&lt;BR /&gt; 55         data want;&lt;BR /&gt;56            set data (firstobs=2);&lt;BR /&gt;ERROR: File WORK.DATA.DATA does not exist.&lt;BR /&gt;SYMBOLGEN:  Macro variable RENAMES resolves to a=dept                                                                                                                                                                                                  &lt;BR /&gt;57            rename &amp;amp;renames;&lt;BR /&gt;58         run;&lt;BR /&gt;&lt;BR /&gt;WARNING: The variable a in the DROP, KEEP, or RENAME list has never been referenced.&lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;WARNING: The data set WORK.WANT may be incomplete.  When this step was stopped there were 0 observations and 0 variables.&lt;BR /&gt;WARNING: Data set WORK.WANT was not replaced because this step was stopped.&lt;BR /&gt;NOTE: DATA statement used (Total process time):</description>
      <pubDate>Thu, 27 May 2021 15:08:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Make-row-one-the-header-in-datastep/m-p/744186#M233109</guid>
      <dc:creator>Q1983</dc:creator>
      <dc:date>2021-05-27T15:08:31Z</dc:date>
    </item>
    <item>
      <title>Re: Make row one the header in datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Make-row-one-the-header-in-datastep/m-p/744189#M233111</link>
      <description>&lt;P&gt;So your dataset is not named DATA. Use the actual name of your existing dataset.&lt;/P&gt;
&lt;P&gt;Also either your first step excluded the SEPARATED BY ' ' clause or your dataset only had one variable.&lt;/P&gt;</description>
      <pubDate>Thu, 27 May 2021 15:22:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Make-row-one-the-header-in-datastep/m-p/744189#M233111</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-05-27T15:22:49Z</dc:date>
    </item>
    <item>
      <title>Re: Make row one the header in datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Make-row-one-the-header-in-datastep/m-p/744190#M233112</link>
      <description>Did the rest of the code run correctly? Show your full log, I suspect your issue is at the first step and it flowed through.</description>
      <pubDate>Thu, 27 May 2021 15:22:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Make-row-one-the-header-in-datastep/m-p/744190#M233112</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-05-27T15:22:34Z</dc:date>
    </item>
  </channel>
</rss>

