<?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: Add variable names to the first row of data within dataset and insert row above with value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Add-variable-names-to-the-first-row-of-data-within-dataset-and/m-p/607912#M176820</link>
    <description>&lt;P&gt;&lt;A href="https://documentation.sas.com/?docsetId=lestmtsref&amp;amp;docsetTarget=n1r8ub0jx34xfsn1ppcjfe0u16pc.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en"&gt;https://documentation.sas.com/?docsetId=lestmtsref&amp;amp;docsetTarget=n1r8ub0jx34xfsn1ppcjfe0u16pc.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 27 Nov 2019 23:53:31 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2019-11-27T23:53:31Z</dc:date>
    <item>
      <title>Add variable names to the first row of data within dataset and insert row above with value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-variable-names-to-the-first-row-of-data-within-dataset-and/m-p/607910#M176818</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was wondering if it is possible to be able and have SAS include a datasets headers in the first row of the data and also insert a row above that with a string value in the first column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below I've included some code which shows my sample data and what I am looking to achieve.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any other questions or further information let me know.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sandy&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let have_id = 'abc123';

proc sql noprint;
    create table work.have_data (test1 char(6),test2 char(6),test3 char(6))
    ;
    insert into work.have_data (test1,test2,test3)
        values ('a','b','c')
		values ('d','e','f')
		values ('g','h','i')
		values ('j','k','l')
    ;
quit;

proc sql noprint;
    create table work.want (col1 char(6),col2 char(6),col3 char(6))
    ;
    insert into work.want (col1,col2,col3)
		values (&amp;amp;have_id,'','')
		values ('test1','test2','test3')
        values ('a','b','c')
		values ('d','e','f')
		values ('g','h','i')
		values ('j','k','l')
    ;
quit;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Nov 2019 23:49:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-variable-names-to-the-first-row-of-data-within-dataset-and/m-p/607910#M176818</guid>
      <dc:creator>Sanflo</dc:creator>
      <dc:date>2019-11-27T23:49:03Z</dc:date>
    </item>
    <item>
      <title>Re: Add variable names to the first row of data within dataset and insert row above with value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-variable-names-to-the-first-row-of-data-within-dataset-and/m-p/607911#M176819</link>
      <description>Why not use variable labels and/or data set labels if needed?</description>
      <pubDate>Wed, 27 Nov 2019 23:51:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-variable-names-to-the-first-row-of-data-within-dataset-and/m-p/607911#M176819</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-11-27T23:51:48Z</dc:date>
    </item>
    <item>
      <title>Re: Add variable names to the first row of data within dataset and insert row above with value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-variable-names-to-the-first-row-of-data-within-dataset-and/m-p/607912#M176820</link>
      <description>&lt;P&gt;&lt;A href="https://documentation.sas.com/?docsetId=lestmtsref&amp;amp;docsetTarget=n1r8ub0jx34xfsn1ppcjfe0u16pc.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en"&gt;https://documentation.sas.com/?docsetId=lestmtsref&amp;amp;docsetTarget=n1r8ub0jx34xfsn1ppcjfe0u16pc.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Nov 2019 23:53:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-variable-names-to-the-first-row-of-data-within-dataset-and/m-p/607912#M176820</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-11-27T23:53:31Z</dc:date>
    </item>
    <item>
      <title>Re: Add variable names to the first row of data within dataset and insert row above with value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-variable-names-to-the-first-row-of-data-within-dataset-and/m-p/607924#M176827</link>
      <description>&lt;P&gt;What possible value could you get out of that?&lt;/P&gt;
&lt;P&gt;Sounds like you want a print out of your data. Use PROC PRINT.&lt;/P&gt;
&lt;P&gt;Here is an example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let dsn=sashelp.class(obs=3);
title "&amp;amp;dsn";
proc print data=&amp;amp;dsn;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 380px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/34301i400DA55CABFB3641/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Nov 2019 01:19:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-variable-names-to-the-first-row-of-data-within-dataset-and/m-p/607924#M176827</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-11-28T01:19:34Z</dc:date>
    </item>
    <item>
      <title>Re: Add variable names to the first row of data within dataset and insert row above with value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-variable-names-to-the-first-row-of-data-within-dataset-and/m-p/607990#M176867</link>
      <description>&lt;P&gt;No, for several reasons:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;you can't have strings in numeric columns&lt;/LI&gt;
&lt;LI&gt;even if you only had character columns, variable names can easily exceed the defined length of the variable&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Liberate yourself from Excel thinking.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Nov 2019 07:51:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-variable-names-to-the-first-row-of-data-within-dataset-and/m-p/607990#M176867</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-11-28T07:51:47Z</dc:date>
    </item>
  </channel>
</rss>

