<?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: Get the name of each column in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Get-the-name-of-each-column/m-p/762019#M241214</link>
    <description>&lt;P&gt;Note to any interested readers: OP changed the "want" appearance from having all values in a single column the name of the variable to something mixing them after I posted this partial possible solution to the original "want". Without any rules.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If a variable is numeric you cannot place text like a variable name as values in that variable. To hold text the variable must be character. If your variable is character it must have a length long enough to hold the name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can create a format that will show different text for a value though.&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Data have;
    input somevariable;
datalines;
1
;&lt;BR /&gt;&lt;BR /&gt;Proc format;&lt;BR /&gt;value somevariable&lt;BR /&gt;1='somevariable'&lt;BR /&gt;;&lt;BR /&gt;&lt;BR /&gt;proc print data=have;&lt;BR /&gt;   format somevariable somevariable. ;&lt;BR /&gt;run;&lt;/PRE&gt;
&lt;P&gt;You would need one format for each variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 17 Aug 2021 14:14:41 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2021-08-17T14:14:41Z</dc:date>
    <item>
      <title>Get the name of each column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-the-name-of-each-column/m-p/761999#M241206</link>
      <description>&lt;P&gt;Hello Experts,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I wonderring if there is some function that permits us to read the name of column (from first to last).&lt;/P&gt;</description>
      <pubDate>Wed, 18 Aug 2021 11:09:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-the-name-of-each-column/m-p/761999#M241206</guid>
      <dc:creator>SASdevAnneMarie</dc:creator>
      <dc:date>2021-08-18T11:09:20Z</dc:date>
    </item>
    <item>
      <title>Re: Get the name of each column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-the-name-of-each-column/m-p/762002#M241208</link>
      <description>Can you explain with a small example with a 'have' dataset example and 'want' dataset example?&lt;BR /&gt;Is it something like this?:&lt;BR /&gt;Have:&lt;BR /&gt;ID       var1    var2&lt;BR /&gt;J01       1         1&lt;BR /&gt;Want:&lt;BR /&gt;ID       var1    var2&lt;BR /&gt;J01     var1    var2&lt;BR /&gt;?????&lt;BR /&gt;</description>
      <pubDate>Tue, 17 Aug 2021 09:39:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-the-name-of-each-column/m-p/762002#M241208</guid>
      <dc:creator>JosvanderVelden</dc:creator>
      <dc:date>2021-08-17T09:39:49Z</dc:date>
    </item>
    <item>
      <title>Re: Get the name of each column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-the-name-of-each-column/m-p/762004#M241209</link>
      <description>Thank you for your message,&lt;BR /&gt;I added the image of "want" dataset.</description>
      <pubDate>Tue, 17 Aug 2021 09:48:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-the-name-of-each-column/m-p/762004#M241209</guid>
      <dc:creator>SASdevAnneMarie</dc:creator>
      <dc:date>2021-08-17T09:48:08Z</dc:date>
    </item>
    <item>
      <title>Re: Get the name of each column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-the-name-of-each-column/m-p/762019#M241214</link>
      <description>&lt;P&gt;Note to any interested readers: OP changed the "want" appearance from having all values in a single column the name of the variable to something mixing them after I posted this partial possible solution to the original "want". Without any rules.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If a variable is numeric you cannot place text like a variable name as values in that variable. To hold text the variable must be character. If your variable is character it must have a length long enough to hold the name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can create a format that will show different text for a value though.&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Data have;
    input somevariable;
datalines;
1
;&lt;BR /&gt;&lt;BR /&gt;Proc format;&lt;BR /&gt;value somevariable&lt;BR /&gt;1='somevariable'&lt;BR /&gt;;&lt;BR /&gt;&lt;BR /&gt;proc print data=have;&lt;BR /&gt;   format somevariable somevariable. ;&lt;BR /&gt;run;&lt;/PRE&gt;
&lt;P&gt;You would need one format for each variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Aug 2021 14:14:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-the-name-of-each-column/m-p/762019#M241214</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-08-17T14:14:41Z</dc:date>
    </item>
    <item>
      <title>Re: Get the name of each column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-the-name-of-each-column/m-p/762024#M241218</link>
      <description>&lt;P&gt;I feel compelled to ask the obvious questions:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;What is the point of having a data set with ALL values equal to 1?&lt;/LI&gt;
&lt;LI&gt;What is the point of doing work to create the final data set? What is the benefit? What would be the next step after you do the creation of this final data set?&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Tue, 17 Aug 2021 11:27:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-the-name-of-each-column/m-p/762024#M241218</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-08-17T11:27:55Z</dc:date>
    </item>
    <item>
      <title>Re: Get the name of each column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-the-name-of-each-column/m-p/762070#M241240</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/286185"&gt;@SASdevAnneMarie&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello Experts,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I wonderring if there is some function that permits us to read the name of column (from first to last).&lt;/P&gt;
&lt;P&gt;I would like to replace the "1" in each column by the name of the column, the ID in my data is CD_produit.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MarieT_0-1629191309002.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/62649iB78EDC3097879754/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MarieT_0-1629191309002.png" alt="MarieT_0-1629191309002.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to have the data like that (for example for J009)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MarieT_0-1629200756396.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/62651i39DE9A97FABD145F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MarieT_0-1629200756396.png" alt="MarieT_0-1629200756396.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your help !&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Proc transpose will create a _name_ variable for each variable on the VAR statement of the procedure call.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am not going to retype stuff from pictures especially since we can't even tell exactly what one or more of your variable names are because the pictures truncate the names.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Proc transpose data=yourdataset out=transposed;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; by &amp;lt;your grouping variables&amp;gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; var &amp;lt;list all those numeric variables&amp;gt;;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There will be one or more COL variables holding the numeric values. If you don't want those drop them afterwards.&lt;/P&gt;
&lt;P&gt;The data set will need to be sorted by the grouping variables before the Proc transpose.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Aug 2021 14:20:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-the-name-of-each-column/m-p/762070#M241240</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-08-17T14:20:32Z</dc:date>
    </item>
    <item>
      <title>Re: Get the name of each column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-the-name-of-each-column/m-p/762275#M241324</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
 set sashelp.class;
 length _name_ $ 40;
 do until(_name_=' ');
  call vnext(_name_);
  put _name_=;
 end;
 stop;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 Aug 2021 13:01:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-the-name-of-each-column/m-p/762275#M241324</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-08-18T13:01:46Z</dc:date>
    </item>
  </channel>
</rss>

