<?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: Create a new column with values of label of a varaible in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-a-new-column-with-values-of-label-of-a-varaible/m-p/748222#M234979</link>
    <description>&lt;P&gt;The functions that would allow this are not supported in Proc SQL.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So you may try&lt;/P&gt;
&lt;P&gt;1) Select the label from the Dictionary.columns for the variable X for that source data set and join it to this table&lt;/P&gt;
&lt;P&gt;2) Select the label from the dictionary.columns into a macro variable and use that as the value&lt;/P&gt;</description>
    <pubDate>Tue, 15 Jun 2021 20:42:21 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2021-06-15T20:42:21Z</dc:date>
    <item>
      <title>Create a new column with values of label of a varaible</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-new-column-with-values-of-label-of-a-varaible/m-p/748218#M234976</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;raw_tbl contain the following columns:&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;ID&amp;nbsp;(label:&amp;nbsp;Customer&amp;nbsp;ID)&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;X&amp;nbsp;(label:&amp;nbsp;Indicator&amp;nbsp;good/bad&amp;nbsp;credit&amp;nbsp;card&amp;nbsp;user)&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;w&amp;nbsp;(label:&amp;nbsp;Indicator&amp;nbsp;good/bad&amp;nbsp;loans taker)&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;I&amp;nbsp;want&amp;nbsp;to&amp;nbsp;create&amp;nbsp;a&amp;nbsp;summary&amp;nbsp;table&amp;nbsp;and&amp;nbsp;add&amp;nbsp;a&amp;nbsp;column&amp;nbsp;called&amp;nbsp;label_of_Var&amp;nbsp;that&amp;nbsp;will&amp;nbsp;&lt;/CODE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;CODE class=" language-sas"&gt;get&amp;nbsp;the&amp;nbsp;value&amp;nbsp;of&amp;nbsp;label&amp;nbsp;of&amp;nbsp;Var&amp;nbsp;X?&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;What&amp;nbsp;is&amp;nbsp;the&amp;nbsp;way&amp;nbsp;to&amp;nbsp;do&amp;nbsp;it&amp;nbsp;please?&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;In&amp;nbsp;this&amp;nbsp;example&amp;nbsp;I&amp;nbsp;wrote&amp;nbsp;it&amp;nbsp;manually&amp;nbsp;"Indicator&amp;nbsp;good/bad&amp;nbsp;credit&amp;nbsp;card&amp;nbsp;user" as label_of_Var&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;But&amp;nbsp;my&amp;nbsp;question&amp;nbsp;is&amp;nbsp;how&amp;nbsp;to&amp;nbsp;create&amp;nbsp;a&amp;nbsp;code&amp;nbsp;that&amp;nbsp;put&amp;nbsp;automatically&amp;nbsp;label&amp;nbsp;of&amp;nbsp;X&amp;nbsp;as&amp;nbsp;a&amp;nbsp;value&amp;nbsp;of&amp;nbsp;column&amp;nbsp;label_of_Var?&lt;/CODE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
Create table wanted_x as
select  "Ind_X" as Var,
            "Indicator&amp;nbsp;good/bad&amp;nbsp;credit&amp;nbsp;card&amp;nbsp;user" as label_of_Var,
           case when Ind_X=1 then 'Fail' else 'Pass' end as Ind_pass_Fail,
          count(*) as nr,
         calculated nr/(select count(*) from raw_tbl) as pct
From  raw_tbl
group by calculated Ind_pass_Fail;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 15 Jun 2021 20:16:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-new-column-with-values-of-label-of-a-varaible/m-p/748218#M234976</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2021-06-15T20:16:10Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new column with values of label of a varaible</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-new-column-with-values-of-label-of-a-varaible/m-p/748222#M234979</link>
      <description>&lt;P&gt;The functions that would allow this are not supported in Proc SQL.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So you may try&lt;/P&gt;
&lt;P&gt;1) Select the label from the Dictionary.columns for the variable X for that source data set and join it to this table&lt;/P&gt;
&lt;P&gt;2) Select the label from the dictionary.columns into a macro variable and use that as the value&lt;/P&gt;</description>
      <pubDate>Tue, 15 Jun 2021 20:42:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-new-column-with-values-of-label-of-a-varaible/m-p/748222#M234979</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-06-15T20:42:21Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new column with values of label of a varaible</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-new-column-with-values-of-label-of-a-varaible/m-p/748256#M234992</link>
      <description>&lt;P&gt;Unfortunately the function vlabel is only available in a data step, not in proc sql.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Jun 2021 06:07:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-new-column-with-values-of-label-of-a-varaible/m-p/748256#M234992</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-06-16T06:07:15Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new column with values of label of a varaible</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-new-column-with-values-of-label-of-a-varaible/m-p/748257#M234993</link>
      <description>&lt;P&gt;Use macro variables:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let varname=Ind_X;

proc sql noprint;
select label into :varlabel
from dictionary.columns
where libname = "WORK" and memname = "RAW_TBL" and upcase(name) = upcase("&amp;amp;varname.")
;
create table wanted_x as
  select
    "&amp;amp;varname." as Var,
    "&amp;amp;varlabel." as label_of_Var,
    case when Ind_X=1 then 'Fail' else 'Pass' end as Ind_pass_Fail,
    count(*) as nr,
    calculated nr/(select count(*) from raw_tbl) as pct
  from raw_tbl
  group by calculated Ind_pass_Fail
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Jun 2021 06:15:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-new-column-with-values-of-label-of-a-varaible/m-p/748257#M234993</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-06-16T06:15:46Z</dc:date>
    </item>
  </channel>
</rss>

