<?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: Variable name from first observation in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Variable-name-from-first-observation/m-p/726703#M225849</link>
    <description>Better post some REAL data , not just a picture .</description>
    <pubDate>Tue, 16 Mar 2021 11:11:23 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2021-03-16T11:11:23Z</dc:date>
    <item>
      <title>Variable name from first observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-name-from-first-observation/m-p/726667#M225827</link>
      <description>&lt;P&gt;Hello Experts,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My data is :&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MarieT_0-1615888014937.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/55993i0962F095A8BD02F3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MarieT_0-1615888014937.png" alt="MarieT_0-1615888014937.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I would like to extract the name from first row and put it as coulumn name. I would like to do that with proc contents and after do the set of two tables. Maybe you know the easiest method ?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your help !&lt;/P&gt;</description>
      <pubDate>Tue, 16 Mar 2021 09:49:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-name-from-first-observation/m-p/726667#M225827</guid>
      <dc:creator>SASdevAnneMarie</dc:creator>
      <dc:date>2021-03-16T09:49:36Z</dc:date>
    </item>
    <item>
      <title>Re: Variable name from first observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-name-from-first-observation/m-p/726685#M225833</link>
      <description>&lt;P&gt;&lt;STRONG&gt;DON'T.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;These are not valid SAS names.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Mar 2021 10:02:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-name-from-first-observation/m-p/726685#M225833</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-03-16T10:02:59Z</dc:date>
    </item>
    <item>
      <title>Re: Variable name from first observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-name-from-first-observation/m-p/726703#M225849</link>
      <description>Better post some REAL data , not just a picture .</description>
      <pubDate>Tue, 16 Mar 2021 11:11:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-name-from-first-observation/m-p/726703#M225849</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-03-16T11:11:23Z</dc:date>
    </item>
    <item>
      <title>Re: Variable name from first observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-name-from-first-observation/m-p/726729#M225866</link>
      <description>&lt;P&gt;If the first row has names, one should be able to do that in the import processes in most scenarios&lt;BR /&gt;Please share how you are importing and atleast the first few rows..&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Mar 2021 12:57:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-name-from-first-observation/m-p/726729#M225866</guid>
      <dc:creator>Sajid01</dc:creator>
      <dc:date>2021-03-16T12:57:05Z</dc:date>
    </item>
    <item>
      <title>Re: Variable name from first observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-name-from-first-observation/m-p/726735#M225869</link>
      <description>&lt;P&gt;PROC TRANSPOSE is the way to do this.&lt;/P&gt;
&lt;P&gt;Let's say your existing dataset is named HAVE.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=have(obs=1) out=names ;
  var _all_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This will produce a dataset with two variables _NAME_ with the orignal names and COL1 with the values from the first row.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The values in your photograph look more like labels than names so let's use this information to generate a LABEL statement instead of a RENAME statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename code temp;
data _null_;
   set names end=eof;
   file code ;
   if _n_=1 then put 'label' ;
  put @3 _name_ '=' col1 :$quote. ;
  if eof then put ';' ;
run;

data want;
  set have(firstobs=2);
  %include code / source2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Mar 2021 13:13:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-name-from-first-observation/m-p/726735#M225869</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-03-16T13:13:23Z</dc:date>
    </item>
  </channel>
</rss>

