<?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 Request for Help with SAS Dates Passing through PROC SQL in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Request-for-Help-with-SAS-Dates-Passing-through-PROC-SQL/m-p/695395#M212199</link>
    <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a piece of code that works if I do this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%LET sd = '1Jul2020'd;

PROC SQL;
CREATE TABLE xxx AS SELECT DISTINCT
xxx
FROM
xxx
WHERE 
date BETWEEN &amp;amp;sd. AND INTNX('month', &amp;amp;sd., 3, 'same') - 1;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But if I do&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA _NULL_;
start_date = MDY(%SUBSTR(&amp;amp;quarter., 6, 1) * 3 - 2, 1, %SUBSTR(&amp;amp;quarter., 1, 4));
CALL SYMPUT('start_date', start_date);
...
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And replace&amp;nbsp;&amp;amp;sd. with&amp;nbsp;&amp;amp;start_date., what passes through PROC SQL is a SAS date and returns incorrect/nil data - how do I turn my newly created start_date variable into something that's useable?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've googled this and tried a few things and can't find anything that I can use unfortunately&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help&lt;/P&gt;</description>
    <pubDate>Fri, 30 Oct 2020 02:43:28 GMT</pubDate>
    <dc:creator>---</dc:creator>
    <dc:date>2020-10-30T02:43:28Z</dc:date>
    <item>
      <title>Request for Help with SAS Dates Passing through PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Request-for-Help-with-SAS-Dates-Passing-through-PROC-SQL/m-p/695395#M212199</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a piece of code that works if I do this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%LET sd = '1Jul2020'd;

PROC SQL;
CREATE TABLE xxx AS SELECT DISTINCT
xxx
FROM
xxx
WHERE 
date BETWEEN &amp;amp;sd. AND INTNX('month', &amp;amp;sd., 3, 'same') - 1;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But if I do&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA _NULL_;
start_date = MDY(%SUBSTR(&amp;amp;quarter., 6, 1) * 3 - 2, 1, %SUBSTR(&amp;amp;quarter., 1, 4));
CALL SYMPUT('start_date', start_date);
...
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And replace&amp;nbsp;&amp;amp;sd. with&amp;nbsp;&amp;amp;start_date., what passes through PROC SQL is a SAS date and returns incorrect/nil data - how do I turn my newly created start_date variable into something that's useable?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've googled this and tried a few things and can't find anything that I can use unfortunately&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help&lt;/P&gt;</description>
      <pubDate>Fri, 30 Oct 2020 02:43:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Request-for-Help-with-SAS-Dates-Passing-through-PROC-SQL/m-p/695395#M212199</guid>
      <dc:creator>---</dc:creator>
      <dc:date>2020-10-30T02:43:28Z</dc:date>
    </item>
    <item>
      <title>Re: Request for Help with SAS Dates Passing through PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Request-for-Help-with-SAS-Dates-Passing-through-PROC-SQL/m-p/695396#M212200</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA _NULL_;
start_date = MDY(input(SUBSTR("&amp;amp;quarter.", 6, 1),1.) * 3 - 2, 1, input(SUBSTR("&amp;amp;quarter.", 1, 4),4.));
CALL SYMPUT('start_date', start_date);
...
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If this doesn't work then you will need to post how you assign QUARTER.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Oct 2020 02:53:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Request-for-Help-with-SAS-Dates-Passing-through-PROC-SQL/m-p/695396#M212200</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2020-10-30T02:53:44Z</dc:date>
    </item>
    <item>
      <title>Re: Request for Help with SAS Dates Passing through PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Request-for-Help-with-SAS-Dates-Passing-through-PROC-SQL/m-p/695400#M212202</link>
      <description>&lt;P&gt;Thanks for your prompt response&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've forgotten about the quotes, thanks for pointing that out - however, adding them still gave me the same outcome&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is my quarter variable&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%LET quarter = 2020Q3;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Ultimately I was able to generate a start_date = 1 July 2020 even with my old code but this is 22097 in SAS without applying format and it's attempting to pass 22097 into the PROC SQL where statement rather than '1Jul2020'd&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried turning the date into a character and then add ''d to it but none seem to work - any other advice would be greatly appreciated&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Oct 2020 03:54:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Request-for-Help-with-SAS-Dates-Passing-through-PROC-SQL/m-p/695400#M212202</guid>
      <dc:creator>---</dc:creator>
      <dc:date>2020-10-30T03:54:45Z</dc:date>
    </item>
    <item>
      <title>Re: Request for Help with SAS Dates Passing through PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Request-for-Help-with-SAS-Dates-Passing-through-PROC-SQL/m-p/695401#M212203</link>
      <description>&lt;P&gt;Just played with the codes a bit more and found that this would work - what I hadn't tried was using double rather than single quotes... &lt;span class="lia-unicode-emoji" title=":expressionless_face:"&gt;😑&lt;/span&gt;&amp;nbsp;feels like banging my head against the wall&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA _NULL_;
	date = MDY(SUBSTR("&amp;amp;quarter.", 6, 1) * 3, 1, SUBSTR("&amp;amp;quarter.", 1, 4));
	CALL SYMPUTX('date', PUT(date, DATE9.));
RUN;

PROC SQL;
	CREATE TABLE xxx AS SELECT DISTINCT
	    xxx
	FROM
		xxx
	WHERE 
		date BETWEEN "&amp;amp;date."d AND "&lt;/CODE&gt;&amp;amp;date."d;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;QUIT;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Oct 2020 05:24:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Request-for-Help-with-SAS-Dates-Passing-through-PROC-SQL/m-p/695401#M212203</guid>
      <dc:creator>---</dc:creator>
      <dc:date>2020-10-30T05:24:58Z</dc:date>
    </item>
    <item>
      <title>Re: Request for Help with SAS Dates Passing through PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Request-for-Help-with-SAS-Dates-Passing-through-PROC-SQL/m-p/695402#M212204</link>
      <description>&lt;P&gt;So you are expecting 2020Q3 to convert to a SAS date of 01 July 2020?&lt;/P&gt;</description>
      <pubDate>Fri, 30 Oct 2020 05:28:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Request-for-Help-with-SAS-Dates-Passing-through-PROC-SQL/m-p/695402#M212204</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2020-10-30T05:28:42Z</dc:date>
    </item>
    <item>
      <title>Re: Request for Help with SAS Dates Passing through PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Request-for-Help-with-SAS-Dates-Passing-through-PROC-SQL/m-p/695403#M212205</link>
      <description>Yes among other things - I think there might be a date format that can convert more elegantly but it worked for me &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 30 Oct 2020 05:32:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Request-for-Help-with-SAS-Dates-Passing-through-PROC-SQL/m-p/695403#M212205</guid>
      <dc:creator>---</dc:creator>
      <dc:date>2020-10-30T05:32:05Z</dc:date>
    </item>
    <item>
      <title>Re: Request for Help with SAS Dates Passing through PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Request-for-Help-with-SAS-Dates-Passing-through-PROC-SQL/m-p/695596#M212278</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/354791"&gt;@---&lt;/a&gt;&amp;nbsp; - This is a bit cleaner:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let quarter = 2020Q3;

data test;                                     
   sasdate=input("&amp;amp;quarter",yyq6.);                           
   put sasdate date9.;              
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 30 Oct 2020 21:32:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Request-for-Help-with-SAS-Dates-Passing-through-PROC-SQL/m-p/695596#M212278</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2020-10-30T21:32:36Z</dc:date>
    </item>
  </channel>
</rss>

