<?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 Unable to get value instead column name is printed in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Unable-to-get-value-instead-column-name-is-printed/m-p/699020#M213827</link>
    <description>&lt;P&gt;Dataset has Year column, followed by 53 columns for each week starting from EH_WEEK_1, EH_WEEK_2 and so on upto EH_WEEK_53. I am trying to get the value under that particular week on specifying date. For eg,if I give as 29Sep2020 I am able to identify the week as 40 using WEEK function and then pass it through a macro variable and concatinate it with string "EH_WEEK_".But how do I get that value under EH_WEEK_40 by making it dynamic. Below is the snippet of the same:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%LET WeekEnd =&amp;nbsp; cats("EH_WEEK_", WEEK("29Sep2020"d,'V'));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;/P&gt;&lt;P&gt;CREATE TABLE WEEK_VALS as&lt;/P&gt;&lt;P&gt;SELECT YEAR, &amp;amp;WeekEnd as Weekly_Value&lt;/P&gt;&lt;P&gt;FROM FIT_TABLE&lt;/P&gt;&lt;P&gt;WHERE (conditions)&lt;/P&gt;&lt;P&gt;QUIT;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get that while selecting column it is just passing the value from &amp;amp;WeekEnd variable which is "EH_WEEK_40" and the entire column is printed but how to get the value under EH_WEEK_40 column here?&lt;/P&gt;</description>
    <pubDate>Mon, 16 Nov 2020 04:00:07 GMT</pubDate>
    <dc:creator>udupa_13</dc:creator>
    <dc:date>2020-11-16T04:00:07Z</dc:date>
    <item>
      <title>Unable to get value instead column name is printed</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unable-to-get-value-instead-column-name-is-printed/m-p/699020#M213827</link>
      <description>&lt;P&gt;Dataset has Year column, followed by 53 columns for each week starting from EH_WEEK_1, EH_WEEK_2 and so on upto EH_WEEK_53. I am trying to get the value under that particular week on specifying date. For eg,if I give as 29Sep2020 I am able to identify the week as 40 using WEEK function and then pass it through a macro variable and concatinate it with string "EH_WEEK_".But how do I get that value under EH_WEEK_40 by making it dynamic. Below is the snippet of the same:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%LET WeekEnd =&amp;nbsp; cats("EH_WEEK_", WEEK("29Sep2020"d,'V'));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;/P&gt;&lt;P&gt;CREATE TABLE WEEK_VALS as&lt;/P&gt;&lt;P&gt;SELECT YEAR, &amp;amp;WeekEnd as Weekly_Value&lt;/P&gt;&lt;P&gt;FROM FIT_TABLE&lt;/P&gt;&lt;P&gt;WHERE (conditions)&lt;/P&gt;&lt;P&gt;QUIT;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get that while selecting column it is just passing the value from &amp;amp;WeekEnd variable which is "EH_WEEK_40" and the entire column is printed but how to get the value under EH_WEEK_40 column here?&lt;/P&gt;</description>
      <pubDate>Mon, 16 Nov 2020 04:00:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unable-to-get-value-instead-column-name-is-printed/m-p/699020#M213827</guid>
      <dc:creator>udupa_13</dc:creator>
      <dc:date>2020-11-16T04:00:07Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to get value instead column name is printed</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unable-to-get-value-instead-column-name-is-printed/m-p/699026#M213830</link>
      <description>&lt;P&gt;SQL is doing what you asked it to do.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
CREATE TABLE WEEK_VALS as
  SELECT YEAR
       ,  cats("EH_WEEK_", WEEK("29Sep2020"d,'V')) as Weekly_Value
  FROM FIT_TABLE
;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What code did you want it to run for that 2SEP2020 date?&lt;/P&gt;
&lt;P&gt;Did you mean to run this code?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
CREATE TABLE WEEK_VALS as
  SELECT YEAR
       ,  EH_WEEK_40 as Weekly_Value
  FROM FIT_TABLE
;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In that case you would need to put the value EH_WEEK_40 into the macro variable.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%LET WeekEnd =  EH_WEEK_%sysfunc(week("29Sep2020"d,V));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Nov 2020 04:18:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unable-to-get-value-instead-column-name-is-printed/m-p/699026#M213830</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-11-16T04:18:27Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to get value instead column name is printed</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unable-to-get-value-instead-column-name-is-printed/m-p/699368#M213952</link>
      <description>Thanks for the solution. I tried sysfunc before in a different way but was concatenating in the end.</description>
      <pubDate>Tue, 17 Nov 2020 05:08:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unable-to-get-value-instead-column-name-is-printed/m-p/699368#M213952</guid>
      <dc:creator>udupa_13</dc:creator>
      <dc:date>2020-11-17T05:08:04Z</dc:date>
    </item>
  </channel>
</rss>

