<?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: Proc sql: Adding &amp;quot;where clause variable&amp;quot; to &amp;quot;select clause&amp;quot; inside put() yie in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-Adding-quot-where-clause-variable-quot-to-quot-select/m-p/508613#M136617</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I still don't understand your problem well, but you want to convert numeric variable to characteristic variable in SQL, right??&lt;/P&gt;&lt;P&gt;Your format "16." in PUT function is what I don't know well. Anyway, how about this?&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
    date=today(); year=year(date); output;
    date=today()-100;  year=year(date); output;
    date=today()-1000; year=year(date); output;
run;
proc sql;
    create table work.test_1 as
    select *, put(year, best.)
    from work.test
    where year eq 2018
    ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 30 Oct 2018 09:26:04 GMT</pubDate>
    <dc:creator>KentaMURANAKA</dc:creator>
    <dc:date>2018-10-30T09:26:04Z</dc:date>
    <item>
      <title>Proc sql: Adding "where clause variable" to "select clause" inside put() yields zero results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-Adding-quot-where-clause-variable-quot-to-quot-select/m-p/508593#M136608</link>
      <description>&lt;P&gt;I have a proc sql query containing year(date)=2018 in the where-clause and everything works normally. However, I needed to add a year(date) variable to select-clause in character format so I tried to add "put(year(date),16.)"&amp;nbsp; but didnt get any results. I automatically started to search error in my where-condition but surprisingly didnt find any and confirmed that this new variable in select-clause causes the zero results (no error messages but only no results). Does anyone know why this happens? This doesnt happen in SQLServer. There seems to be connection between the year(date) variable in select-clause and where-clause although shouldnt ( I removed the year(date) from where-clause and got results again). Please see example below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#00ffff"&gt;Works:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;select id, year(date) from data1&lt;/P&gt;&lt;P&gt;where year(date)=2018&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#ff0000"&gt;Doesnt yield any results nor error messages:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;select id,put(year(date),16.) from data1&lt;/P&gt;&lt;P&gt;where year(date)=2018&lt;/P&gt;</description>
      <pubDate>Tue, 30 Oct 2018 07:56:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-Adding-quot-where-clause-variable-quot-to-quot-select/m-p/508593#M136608</guid>
      <dc:creator>aleksi555</dc:creator>
      <dc:date>2018-10-30T07:56:34Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql: Adding "where clause variable" to "select clause" inside put() yie</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-Adding-quot-where-clause-variable-quot-to-quot-select/m-p/508613#M136617</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I still don't understand your problem well, but you want to convert numeric variable to characteristic variable in SQL, right??&lt;/P&gt;&lt;P&gt;Your format "16." in PUT function is what I don't know well. Anyway, how about this?&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
    date=today(); year=year(date); output;
    date=today()-100;  year=year(date); output;
    date=today()-1000; year=year(date); output;
run;
proc sql;
    create table work.test_1 as
    select *, put(year, best.)
    from work.test
    where year eq 2018
    ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 Oct 2018 09:26:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-Adding-quot-where-clause-variable-quot-to-quot-select/m-p/508613#M136617</guid>
      <dc:creator>KentaMURANAKA</dc:creator>
      <dc:date>2018-10-30T09:26:04Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql: Adding "where clause variable" to "select clause" inside put() yie</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-Adding-quot-where-clause-variable-quot-to-quot-select/m-p/508699#M136664</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/153636"&gt;@aleksi555&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have a proc sql query containing year(date)=2018 in the where-clause and everything works normally. However, I needed to add a year(date) variable to select-clause in character format so I tried to add "put(year(date),16.)"&amp;nbsp; but didnt get any results. I automatically started to search error in my where-condition but surprisingly didnt find any and confirmed that this new variable in select-clause causes the zero results (no error messages but only no results). Does anyone know why this happens? This doesnt happen in SQLServer. There seems to be connection between the year(date) variable in select-clause and where-clause although shouldnt ( I removed the year(date) from where-clause and got results again). Please see example below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#00ffff"&gt;Works:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;select id, year(date) from data1&lt;/P&gt;
&lt;P&gt;where year(date)=2018&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#ff0000"&gt;Doesnt yield any results nor error messages:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;select id,put(year(date),16.) from data1&lt;/P&gt;
&lt;P&gt;where year(date)=2018&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You did not give SQL the Name of the resulting value: put(year(date),16.)&amp;nbsp;as YearChar&lt;/P&gt;
&lt;P&gt;or what ever the name of the result should be. I would question using 16 characters though.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Oct 2018 14:12:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-Adding-quot-where-clause-variable-quot-to-quot-select/m-p/508699#M136664</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-10-30T14:12:56Z</dc:date>
    </item>
  </channel>
</rss>

