<?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: Wide to Long of 1 row with adding vars labels info in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Wide-to-Long-of-1-row-with-adding-vars-labels-info/m-p/795138#M255018</link>
    <description>&lt;P&gt;Try this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set have;
   array x x:;
   do over x;
      field_name = vname(x);
	  field_label = vlabel(x);
	  value = x;
	  output;
   end;
   keep field_name field_label value;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;field_name field_label value 
X1         abc         100 
X2         frg         200 
X3         Per         50 
X4         Tim         300 
X5         Loc         180 &lt;/PRE&gt;</description>
    <pubDate>Wed, 09 Feb 2022 10:27:47 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2022-02-09T10:27:47Z</dc:date>
    <item>
      <title>Wide to Long of 1 row with adding vars labels info</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Wide-to-Long-of-1-row-with-adding-vars-labels-info/m-p/795136#M255017</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;What is the way to create wanted data set from have data set?&lt;/P&gt;
&lt;P&gt;This is transpose of one row (wide) into long with putting var labels into one column in the desired data set&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data have;
label X1='abc' X2='frg' X3='Per' X4='Tim'  X5='Loc';
input X1 X2 X3 X4 X5;
cards;
100 200 50 300 180
;
Run;


Data wanted;
input field_name $ field_label $ value;
cards;
X1 abc 100
X2 frg 200
X3 per 50
X4 Tim 300
X5 Loc 180
;
Run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 Feb 2022 10:22:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Wide-to-Long-of-1-row-with-adding-vars-labels-info/m-p/795136#M255017</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2022-02-09T10:22:04Z</dc:date>
    </item>
    <item>
      <title>Re: Wide to Long of 1 row with adding vars labels info</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Wide-to-Long-of-1-row-with-adding-vars-labels-info/m-p/795138#M255018</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set have;
   array x x:;
   do over x;
      field_name = vname(x);
	  field_label = vlabel(x);
	  value = x;
	  output;
   end;
   keep field_name field_label value;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;field_name field_label value 
X1         abc         100 
X2         frg         200 
X3         Per         50 
X4         Tim         300 
X5         Loc         180 &lt;/PRE&gt;</description>
      <pubDate>Wed, 09 Feb 2022 10:27:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Wide-to-Long-of-1-row-with-adding-vars-labels-info/m-p/795138#M255018</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-02-09T10:27:47Z</dc:date>
    </item>
    <item>
      <title>Re: Wide to Long of 1 row with adding vars labels info</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Wide-to-Long-of-1-row-with-adding-vars-labels-info/m-p/795140#M255019</link>
      <description>&lt;P&gt;Proc transpose can do this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=have out=want(rename=(col1 = value)) label=field_label name=field_name;
   var x1-x5;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 Feb 2022 10:33:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Wide-to-Long-of-1-row-with-adding-vars-labels-info/m-p/795140#M255019</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2022-02-09T10:33:09Z</dc:date>
    </item>
  </channel>
</rss>

