<?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: Variable created by %Let is character. I need to to be numeric so I can use it in PROC SQL to in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Variable-created-by-Let-is-character-I-need-to-to-be-numeric-so/m-p/574482#M162341</link>
    <description>Ok ... here it just says: NOT resolved. But I had a problem earlier SAS complained it was character. Or I am just confused. The thing is I need to run this for various programs for different dates. I need this &amp;amp;x_target_run_dt variable.</description>
    <pubDate>Thu, 18 Jul 2019 08:07:50 GMT</pubDate>
    <dc:creator>Longimanus</dc:creator>
    <dc:date>2019-07-18T08:07:50Z</dc:date>
    <item>
      <title>Variable created by %Let is character. I need to to be numeric so I can use it in PROC SQL to</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-created-by-Let-is-character-I-need-to-to-be-numeric-so/m-p/574478#M162337</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hi there! I am running some tests and am a little (very) rusty.&amp;nbsp; I need to run a simple sql. I want to run this in SAS Base.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like the x_target_run_dt variable to be 18352 (the 31MAR2010).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I use:&amp;nbsp; %let&amp;nbsp;x_target_run_dt = 18352;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the &amp;amp;x_target_run_dt will be character and contain '18312'.&amp;nbsp; The VALID_FROM_DTTM and VALID_TO_DTTM columns are numeric and the SQL doesn't like this.&amp;nbsp; How do I fix this?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;&amp;nbsp; create table work.W5FEMUWG_FAC as&lt;BR /&gt;&amp;nbsp; select&lt;BR /&gt;&amp;nbsp; ACCOUNT_RK &lt;BR /&gt;&amp;nbsp; &amp;nbsp; format = BEST12.&lt;BR /&gt;&amp;nbsp; &amp;nbsp; informat = BEST12.&lt;BR /&gt;&amp;nbsp; &amp;nbsp; label = 'Account Key',&lt;BR /&gt;BALANCE_AMT &lt;BR /&gt;&amp;nbsp; &amp;nbsp;format = DOLLAR22.2&lt;BR /&gt;&amp;nbsp; &amp;nbsp;informat = DOLLAR22.2,&lt;BR /&gt;&amp;nbsp; &amp;nbsp;X_DEBIT_INTEREST &lt;BR /&gt;&amp;nbsp; &amp;nbsp;label = 'Debit Interest'&lt;BR /&gt;from lib_dds.tablewithfromandtodates&amp;nbsp;&lt;BR /&gt;where (&amp;amp;x_target_run_dt Between DATEPART(VALID_FROM_DTTM) And DATEPART(VALID_TO_DTTM));&lt;BR /&gt;quit;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2019 08:03:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-created-by-Let-is-character-I-need-to-to-be-numeric-so/m-p/574478#M162337</guid>
      <dc:creator>Longimanus</dc:creator>
      <dc:date>2019-07-18T08:03:10Z</dc:date>
    </item>
    <item>
      <title>Re: Variable created by %Let is character. I need to to be numeric so I can use it in PROC SQL to</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-created-by-Let-is-character-I-need-to-to-be-numeric-so/m-p/574479#M162338</link>
      <description>&lt;P&gt;What does the log say?&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2019 08:00:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-created-by-Let-is-character-I-need-to-to-be-numeric-so/m-p/574479#M162338</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-07-18T08:00:56Z</dc:date>
    </item>
    <item>
      <title>Re: Variable created by %Let is character. I need to to be numeric so I can use it in PROC SQL to</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-created-by-Let-is-character-I-need-to-to-be-numeric-so/m-p/574480#M162339</link>
      <description>Well ... this: &lt;BR /&gt;&lt;BR /&gt;NOTE: Remote submit to LEV3 commencing.&lt;BR /&gt;69   %let datumin5digits = 18352;&lt;BR /&gt;70   %let cc = se;&lt;BR /&gt;71&lt;BR /&gt;72   %let SYSLAST = %nrquote(dds_&amp;amp;cc..FINANCIAL_ACCOUNT_CHNG);&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;73   proc datasets lib = work nolist nowarn memtype = (data view);&lt;BR /&gt;74      delete W5FEMUWG_FAC;&lt;BR /&gt;75   quit;&lt;BR /&gt;&lt;BR /&gt;NOTE: PROCEDURE DATASETS used (Total process time):&lt;BR /&gt;      real time           0.00 seconds&lt;BR /&gt;      cpu time            0.00 seconds&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;76   proc sql;&lt;BR /&gt;77      create table work.W5FEMUWG_FAC as&lt;BR /&gt;78         select&lt;BR /&gt;79            ACCOUNT_RK&lt;BR /&gt;80               format = BEST12.&lt;BR /&gt;81               informat = BEST12.&lt;BR /&gt;82               label = 'Account Key',&lt;BR /&gt;83            BALANCE_AMT&lt;BR /&gt;84               format = DOLLAR22.2&lt;BR /&gt;85               informat = DOLLAR22.2,&lt;BR /&gt;86            X_DEBIT_INTEREST&lt;BR /&gt;87               label = 'Debit Interest'&lt;BR /&gt;88      from &amp;amp;SYSLAST&lt;BR /&gt;89         where (&amp;amp;x_target_run_dt Between DATEPART(VALID_FROM_DTTM) And DATEPART(VALID_TO_DTTM))&lt;BR /&gt;                  -&lt;BR /&gt;                  22&lt;BR /&gt;WARNING: Apparent symbolic reference X_TARGET_RUN_DT not resolved.&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string,&lt;BR /&gt;              a numeric constant, a datetime constant, a missing value, BTRIM, INPUT, PUT,&lt;BR /&gt;              SUBSTRING, USER.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 18 Jul 2019 08:04:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-created-by-Let-is-character-I-need-to-to-be-numeric-so/m-p/574480#M162339</guid>
      <dc:creator>Longimanus</dc:creator>
      <dc:date>2019-07-18T08:04:44Z</dc:date>
    </item>
    <item>
      <title>Re: Variable created by %Let is character. I need to to be numeric so I can use it in PROC SQL to</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-created-by-Let-is-character-I-need-to-to-be-numeric-so/m-p/574482#M162341</link>
      <description>Ok ... here it just says: NOT resolved. But I had a problem earlier SAS complained it was character. Or I am just confused. The thing is I need to run this for various programs for different dates. I need this &amp;amp;x_target_run_dt variable.</description>
      <pubDate>Thu, 18 Jul 2019 08:07:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-created-by-Let-is-character-I-need-to-to-be-numeric-so/m-p/574482#M162341</guid>
      <dc:creator>Longimanus</dc:creator>
      <dc:date>2019-07-18T08:07:50Z</dc:date>
    </item>
    <item>
      <title>Re: Variable created by %Let is character. I need to to be numeric so I can use it in PROC SQL to</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-created-by-Let-is-character-I-need-to-to-be-numeric-so/m-p/574483#M162342</link>
      <description>Ok wait ... please wait. I did run something weird. I'll be back!</description>
      <pubDate>Thu, 18 Jul 2019 08:09:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-created-by-Let-is-character-I-need-to-to-be-numeric-so/m-p/574483#M162342</guid>
      <dc:creator>Longimanus</dc:creator>
      <dc:date>2019-07-18T08:09:56Z</dc:date>
    </item>
    <item>
      <title>Re: Variable created by %Let is character. I need to to be numeric so I can use it in PROC SQL to</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-created-by-Let-is-character-I-need-to-to-be-numeric-so/m-p/574484#M162343</link>
      <description>&lt;P&gt;I solved it. Sorry! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2019 08:12:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-created-by-Let-is-character-I-need-to-to-be-numeric-so/m-p/574484#M162343</guid>
      <dc:creator>Longimanus</dc:creator>
      <dc:date>2019-07-18T08:12:30Z</dc:date>
    </item>
    <item>
      <title>Re: Variable created by %Let is character. I need to to be numeric so I can use it in PROC SQL to</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-created-by-Let-is-character-I-need-to-to-be-numeric-so/m-p/574485#M162344</link>
      <description>&lt;P&gt;Seems to me that the macro variable&amp;nbsp;&lt;SPAN&gt;x_target_run_dt does not contain a value? PROC SQL should be able to handle this. See the below example&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let dt=11262;

proc sql;
    create table test as
    select * from sashelp.stocks
    where (&amp;amp;dt between date and date);
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 Jul 2019 08:12:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-created-by-Let-is-character-I-need-to-to-be-numeric-so/m-p/574485#M162344</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-07-18T08:12:42Z</dc:date>
    </item>
    <item>
      <title>Re: Variable created by %Let is character. I need to to be numeric so I can use it in PROC SQL to</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-created-by-Let-is-character-I-need-to-to-be-numeric-so/m-p/574487#M162345</link>
      <description>&lt;P&gt;No problem. See my other answer. PROC SQL should be able to handle this. Glad you found your answer &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2019 08:13:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-created-by-Let-is-character-I-need-to-to-be-numeric-so/m-p/574487#M162345</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-07-18T08:13:14Z</dc:date>
    </item>
    <item>
      <title>Re: Variable created by %Let is character. I need to to be numeric so I can use it in PROC SQL to</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-created-by-Let-is-character-I-need-to-to-be-numeric-so/m-p/574488#M162346</link>
      <description>&lt;P&gt;ALWAYS(!!!) debug the first problem first. In your case it's this:&lt;/P&gt;
&lt;PRE&gt;WARNING: Apparent symbolic reference X_TARGET_RUN_DT not resolved.
&lt;/PRE&gt;
&lt;P&gt;Your code as such is OK, see this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data tablewithfromandtodates;
input account_rk balance_amt x_debit_interest valid_from_dttm :datetime19. valid_to_dttm :datetime19.;
format valid_from_dttm valid_to_dttm :datetime19.;
datalines;
1 23 25 01mar2010:00:00:00 30apr2010:23:59:59
;


%let x_target_run_dt = 18352; 

proc sql;
create table work.W5FEMUWG_FAC as
select
  ACCOUNT_RK 
    format = BEST12.
    informat = BEST12.
    label = 'Account Key',
  BALANCE_AMT 
    format = DOLLAR22.2
    informat = DOLLAR22.2,
  X_DEBIT_INTEREST 
    label = 'Debit Interest'
from tablewithfromandtodates 
where &amp;amp;x_target_run_dt Between DATEPART(VALID_FROM_DTTM) And DATEPART(VALID_TO_DTTM);
quit; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Log:&lt;/P&gt;
&lt;PRE&gt;27         %let x_target_run_dt = 18352;
28         
29         proc sql;
30         create table work.W5FEMUWG_FAC as
31         select
32           ACCOUNT_RK
33             format = BEST12.
34             informat = BEST12.
35             label = 'Account Key',
36           BALANCE_AMT
37             format = DOLLAR22.2
38             informat = DOLLAR22.2,
39           X_DEBIT_INTEREST
40             label = 'Debit Interest'
41         from tablewithfromandtodates
42         where &amp;amp;x_target_run_dt Between DATEPART(VALID_FROM_DTTM) And DATEPART(VALID_TO_DTTM);
NOTE: Table WORK.W5FEMUWG_FAC created, with 1 rows and 3 columns.

43         quit;
NOTE: PROZEDUR SQL used (Total process time):
      real time           0.02 seconds
      cpu time            0.00 seconds
      
&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 Jul 2019 08:13:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-created-by-Let-is-character-I-need-to-to-be-numeric-so/m-p/574488#M162346</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-07-18T08:13:38Z</dc:date>
    </item>
    <item>
      <title>Re: Variable created by %Let is character. I need to to be numeric so I can use it in PROC SQL to</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-created-by-Let-is-character-I-need-to-to-be-numeric-so/m-p/574624#M162408</link>
      <description>&lt;P&gt;You show matching you stated value in the first post of 18352&lt;/P&gt;
&lt;PRE&gt;69 %let datumin5digits = 18352;&lt;/PRE&gt;
&lt;P&gt;And then use in proc sql&lt;/P&gt;
&lt;PRE&gt;89 where (&amp;amp;x_target_run_dt Between DATEPART(VALID_FROM_DTTM) And DATEPART(VALID_TO_DTTM))&lt;/PRE&gt;
&lt;P&gt;Perhaps you don't actually have code assigning a value to &amp;amp;x_target_run_dt&amp;nbsp;, or has a value from previous test code? At least you did not show any code assigning a value to that macro variable.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2019 15:17:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-created-by-Let-is-character-I-need-to-to-be-numeric-so/m-p/574624#M162408</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-07-18T15:17:22Z</dc:date>
    </item>
    <item>
      <title>Re: Variable created by %Let is character. I need to to be numeric so I can use it in PROC SQL to</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-created-by-Let-is-character-I-need-to-to-be-numeric-so/m-p/574628#M162412</link>
      <description>&lt;P&gt;Looks like you solved your issue, what ever it was.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But to the question in you subject line:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Macro variables only contain character strings.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How/where you expand the value in your actual SAS code will determine if SAS treats those character strings as numbers or something else.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2019 15:21:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-created-by-Let-is-character-I-need-to-to-be-numeric-so/m-p/574628#M162412</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-07-18T15:21:24Z</dc:date>
    </item>
  </channel>
</rss>

