<?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 display variable label in first row and variable name in second row of a dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-display-variable-label-in-first-row-and-variable-name-in/m-p/833600#M329544</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  input pid age gender race event2 $;
  label
    pid = 'Patient ID'
    age = 'Patient age'
    gender='Sex'
    race = 'Race'
    event2='Event 2'
  ;
cards;
101 21 1 1 fever
102 21 2 1 fever
103 31 1 1 fever
104 43 2 1 fever
;

proc contents data=test noprint out=contents; run;

proc sql noprint;
  select catx(' ','("',label,'" ',name,')')
    into :labels separated by ' '
    from contents
  ;
quit;

%put &amp;amp;labels;
ods excel file='c:\temp\want.xlsx';
proc report data=test nowd;
columns &amp;amp;labels.;
define _all_/display ;
attrib _all_ label=' ';
run;
ods excel close;
proc import datafile='c:\temp\want.xlsx' out=want dbms=xlsx replace;
getnames=no;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1663250530500.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/75282i2E3CE147E96E715A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1663250530500.png" alt="Ksharp_0-1663250530500.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 15 Sep 2022 14:02:09 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2022-09-15T14:02:09Z</dc:date>
    <item>
      <title>How to display variable label in first row and variable name in second row of a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-display-variable-label-in-first-row-and-variable-name-in/m-p/833399#M329448</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;From the test1 dataset, I want to display output like below . It means all variable label should display in first row where as the variable name as second row followed by dataset records.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Output&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Patient ID&amp;nbsp;&amp;nbsp;Patient age&amp;nbsp;&amp;nbsp;Sex&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Race&amp;nbsp; &amp;nbsp; Event 2&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;pid&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; age&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;gender&amp;nbsp; race&amp;nbsp; &amp;nbsp; &amp;nbsp; event2&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 21&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;fever&lt;BR /&gt;102&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 21&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; fever&lt;BR /&gt;103&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;31&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; fever&lt;BR /&gt;104&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;43&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;fever&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data test;&lt;BR /&gt;input pid age gender race event2 $;&lt;BR /&gt;cards;&lt;BR /&gt;101 21 1 1 fever&lt;BR /&gt;102 21 2 1 fever&lt;BR /&gt;103 31 1 1 fever&lt;BR /&gt;104 43 2 1 fever&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;data test1;&lt;BR /&gt;set test;&lt;BR /&gt;label pid = 'Patient ID'&lt;BR /&gt;age = 'Patient age'&lt;BR /&gt;gender='Sex'&lt;BR /&gt;race = 'Race'&lt;BR /&gt;event2='Event 2'&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/PRE&gt;</description>
      <pubDate>Wed, 14 Sep 2022 18:33:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-display-variable-label-in-first-row-and-variable-name-in/m-p/833399#M329448</guid>
      <dc:creator>abraham1</dc:creator>
      <dc:date>2022-09-14T18:33:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to display variable label in first row and variable name in second row of a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-display-variable-label-in-first-row-and-variable-name-in/m-p/833401#M329450</link>
      <description>&lt;P&gt;Do you want this as a SAS data set?&lt;/P&gt;</description>
      <pubDate>Wed, 14 Sep 2022 18:36:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-display-variable-label-in-first-row-and-variable-name-in/m-p/833401#M329450</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-09-14T18:36:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to display variable label in first row and variable name in second row of a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-display-variable-label-in-first-row-and-variable-name-in/m-p/833407#M329454</link>
      <description>&lt;P&gt;Do you mean you want a report like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  input pid age gender race event2 $;
  label
    pid = 'Patient ID'
    age = 'Patient age'
    gender='Sex'
    race = 'Race'
    event2='Event 2'
  ;
cards;
101 21 1 1 fever
102 21 2 1 fever
103 31 1 1 fever
104 43 2 1 fever
;

proc contents data=test noprint out=contents; run;

proc sql noprint;
  select catx('=',nliteral(name),quote(cats(coalesce(label,name),'/',name),"'"))
    into :labels separated by ' '
    from contents
  ;
quit;

proc print data=test split='/' noobs;
  label &amp;amp;labels ;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_1-1663181929306.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/75249i2F88886047CA7DEA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Tom_1-1663181929306.png" alt="Tom_1-1663181929306.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;Patient ID    Patient age      Sex     Race    Event 2
    pid           age        gender    race    event2

    101            21           1        1      fever
    102            21           2        1      fever
    103            31           1        1      fever
    104            43           2        1      fever

&lt;/PRE&gt;</description>
      <pubDate>Wed, 14 Sep 2022 18:59:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-display-variable-label-in-first-row-and-variable-name-in/m-p/833407#M329454</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-09-14T18:59:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to display variable label in first row and variable name in second row of a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-display-variable-label-in-first-row-and-variable-name-in/m-p/833417#M329460</link>
      <description>&lt;P&gt;For CSV/Text files this works:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*This is an example of how to export a data set with two header rows, 
one that is labels and oen that is the variable names
*/

*Create demo data;
data class;
	set sashelp.class;
	label age='Age, Years' weight = 'Weight(lbs)' height='Height, inches';
run;

proc sql noprint;
create table temp as
select name as _name_, label as _label_
from dictionary.columns
where libname="WORK" and upcase(memname)="CLASS";
select cats(quote(name),"n") into :varList separated by ' '
from dictionary.columns
where libname="WORK" and upcase(memname)="CLASS";
quit;

data _null_;
file "&amp;amp;sasforum.\datasets\TwoLinesHeader.csv" dsd;
set class;
if _n_ = 1 then do;
do until(eof);
    set temp end=eof;
    put _name_ @;
    end;
put;
eof = 0;
do until(eof);
    set temp end=eof;
    put _label_ @;
    end;
put;
end;

put (&amp;amp;varList) (:);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 14 Sep 2022 19:19:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-display-variable-label-in-first-row-and-variable-name-in/m-p/833417#M329460</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-09-14T19:19:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to display variable label in first row and variable name in second row of a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-display-variable-label-in-first-row-and-variable-name-in/m-p/833425#M329468</link>
      <description>&lt;P&gt;Or since the OP already has a label statement modify it a bit to use the Split option:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc print data=test noobs label split='*';
   label 
      pid = 'Patient ID*Pid'
      age = 'Patient age*Age'
      gender='Sex*Gender'
      race = 'Race*Race'
      event2='Event 2*Event2'
   ;   
run;&lt;/PRE&gt;</description>
      <pubDate>Wed, 14 Sep 2022 19:51:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-display-variable-label-in-first-row-and-variable-name-in/m-p/833425#M329468</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-09-14T19:51:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to display variable label in first row and variable name in second row of a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-display-variable-label-in-first-row-and-variable-name-in/m-p/833496#M329491</link>
      <description>&lt;P&gt;Thank you so much Tom and Reeza for the solution.&lt;/P&gt;
&lt;P&gt;In stead of using proc print, I want to store this output in a dataset where the label name present in first row and variable name in second row. I tried but both variable label and name print on the single row.&lt;/P&gt;
&lt;P&gt;Its not working. Could you please help me once.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Output like below&lt;/P&gt;
&lt;TABLE width="499"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="101"&gt;Patient ID&lt;/TD&gt;
&lt;TD width="131"&gt;Patient age&lt;/TD&gt;
&lt;TD width="64"&gt;Sex&lt;/TD&gt;
&lt;TD width="64"&gt;Race&lt;/TD&gt;
&lt;TD width="139"&gt;Event 2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;pid&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;age&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;gender&lt;/TD&gt;
&lt;TD&gt;race&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;event2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;101&lt;/TD&gt;
&lt;TD&gt;21&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;fever&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;102&lt;/TD&gt;
&lt;TD&gt;21&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;fever&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;103&lt;/TD&gt;
&lt;TD&gt;31&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;fever&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;104&lt;/TD&gt;
&lt;TD&gt;43&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;fever&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Thu, 15 Sep 2022 05:47:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-display-variable-label-in-first-row-and-variable-name-in/m-p/833496#M329491</guid>
      <dc:creator>abraham1</dc:creator>
      <dc:date>2022-09-15T05:47:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to display variable label in first row and variable name in second row of a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-display-variable-label-in-first-row-and-variable-name-in/m-p/833558#M329525</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/357256"&gt;@abraham1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you so much Tom and Reeza for the solution.&lt;/P&gt;
&lt;P&gt;In stead of using proc print, I want to store this output in a dataset where the label name present in first row and variable name in second row. I tried but both variable label and name print on the single row.&lt;/P&gt;
&lt;P&gt;Its not working. Could you please help me once.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Output like below&lt;/P&gt;
&lt;TABLE width="499"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="101"&gt;Patient ID&lt;/TD&gt;
&lt;TD width="131"&gt;Patient age&lt;/TD&gt;
&lt;TD width="64"&gt;Sex&lt;/TD&gt;
&lt;TD width="64"&gt;Race&lt;/TD&gt;
&lt;TD width="139"&gt;Event 2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;pid&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;age&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;gender&lt;/TD&gt;
&lt;TD&gt;race&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;event2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;101&lt;/TD&gt;
&lt;TD&gt;21&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;fever&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;102&lt;/TD&gt;
&lt;TD&gt;21&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;fever&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;103&lt;/TD&gt;
&lt;TD&gt;31&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;fever&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;104&lt;/TD&gt;
&lt;TD&gt;43&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;fever&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This is not possible. The header of a dataset is limited to a single row. You could extend the labels so that the have both information (already suggested) and activate the option to display labels instead of names.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Sep 2022 11:53:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-display-variable-label-in-first-row-and-variable-name-in/m-p/833558#M329525</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2022-09-15T11:53:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to display variable label in first row and variable name in second row of a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-display-variable-label-in-first-row-and-variable-name-in/m-p/833560#M329526</link>
      <description>&lt;P&gt;This question has already been discussed before .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  input pid age gender race event2 $;
  label
    pid = 'Patient ID'
    age = 'Patient age'
    gender='Sex'
    race = 'Race'
    event2='Event 2'
  ;
cards;
101 21 1 1 fever
102 21 2 1 fever
103 31 1 1 fever
104 43 2 1 fever
;

proc contents data=test noprint out=contents; run;

proc sql noprint;
  select catx(' ','("',label,'" ',name,')')
    into :labels separated by ' '
    from contents
  ;
quit;

%put &amp;amp;labels;

proc report data=test nowd;
columns &amp;amp;labels.;
define _all_/display ;
attrib _all_ label=' ';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1663243461269.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/75274i34C3C074C75A204B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1663243461269.png" alt="Ksharp_0-1663243461269.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Sep 2022 12:04:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-display-variable-label-in-first-row-and-variable-name-in/m-p/833560#M329526</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-09-15T12:04:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to display variable label in first row and variable name in second row of a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-display-variable-label-in-first-row-and-variable-name-in/m-p/833590#M329538</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/357256"&gt;@abraham1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you so much Tom and Reeza for the solution.&lt;/P&gt;
&lt;P&gt;In stead of using proc print, I want to store this output in a dataset where the label name present in first row and variable name in second row. I tried but both variable label and name print on the single row.&lt;/P&gt;
&lt;P&gt;Its not working. Could you please help me once.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Output like below&lt;/P&gt;
&lt;TABLE width="499"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="101"&gt;Patient ID&lt;/TD&gt;
&lt;TD width="131"&gt;Patient age&lt;/TD&gt;
&lt;TD width="64"&gt;Sex&lt;/TD&gt;
&lt;TD width="64"&gt;Race&lt;/TD&gt;
&lt;TD width="139"&gt;Event 2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;pid&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;age&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;gender&lt;/TD&gt;
&lt;TD&gt;race&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;event2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;101&lt;/TD&gt;
&lt;TD&gt;21&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;fever&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;102&lt;/TD&gt;
&lt;TD&gt;21&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;fever&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;103&lt;/TD&gt;
&lt;TD&gt;31&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;fever&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;104&lt;/TD&gt;
&lt;TD&gt;43&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;fever&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Since a DATASET has only one data type per variable if you store that information in a dataset then all of the variables will have to be character.&amp;nbsp; So you will need to convert the numbers like 21 in your table there into strings also.&amp;nbsp; Plus what variable names would you like to use for the variables in this new dataset?&amp;nbsp; Since SAS labels can have up to 256 characters they are too long to use a variable names.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Sep 2022 13:44:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-display-variable-label-in-first-row-and-variable-name-in/m-p/833590#M329538</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-09-15T13:44:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to display variable label in first row and variable name in second row of a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-display-variable-label-in-first-row-and-variable-name-in/m-p/833600#M329544</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  input pid age gender race event2 $;
  label
    pid = 'Patient ID'
    age = 'Patient age'
    gender='Sex'
    race = 'Race'
    event2='Event 2'
  ;
cards;
101 21 1 1 fever
102 21 2 1 fever
103 31 1 1 fever
104 43 2 1 fever
;

proc contents data=test noprint out=contents; run;

proc sql noprint;
  select catx(' ','("',label,'" ',name,')')
    into :labels separated by ' '
    from contents
  ;
quit;

%put &amp;amp;labels;
ods excel file='c:\temp\want.xlsx';
proc report data=test nowd;
columns &amp;amp;labels.;
define _all_/display ;
attrib _all_ label=' ';
run;
ods excel close;
proc import datafile='c:\temp\want.xlsx' out=want dbms=xlsx replace;
getnames=no;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1663250530500.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/75282i2E3CE147E96E715A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1663250530500.png" alt="Ksharp_0-1663250530500.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Sep 2022 14:02:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-display-variable-label-in-first-row-and-variable-name-in/m-p/833600#M329544</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-09-15T14:02:09Z</dc:date>
    </item>
  </channel>
</rss>

