<?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 How to add a %Let Statement to my code? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-Let-Statement-to-my-code/m-p/154305#M30271</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am new to SAS and I am creating a program to compare pricing month over month for the variable "SOC".&amp;nbsp; The code I have so far is below.&amp;nbsp; I need to add a %Let macro statement to the code below so I can enter the month I am looking up.&amp;nbsp; Any help would be appreciated.&amp;nbsp; I am not sure how to do this or where in the code to add it.&amp;nbsp; I am also tring to ensure I do not have any duplicate "SOC" variables.&amp;nbsp; Not sure if using the DISTINCT function will work.&amp;nbsp; I am pulling necessary information from several tables and joining them.&amp;nbsp; Now I need a way to automate this program so it can run it month over month.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;BR /&gt;CREATE TABLE work.mobpp1 AS&lt;BR /&gt;SELECT DISTINCT soc, ban, subscriber_no &lt;BR /&gt;FROM bmlappo.service_agreement&lt;BR /&gt;WHERE subscriber_no ~= '0000000000'&lt;BR /&gt;AND expiration_date IS NULL OR expiration_date&amp;nbsp; &amp;gt;= '15-DEC-2014'd&lt;BR /&gt;GROUP BY soc, ban, subscriber_no;&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;CREATE TABLE work.mobpp2 AS&lt;BR /&gt;SELECT DISTINCT soc, ban, subscriber_no, feature_code, SUM (ACTV_AMT) AS soc_price&lt;BR /&gt;FROM bmlappo.charge&lt;BR /&gt;WHERE sys_creation_date &amp;gt;= '15-DEC-2014'd&lt;BR /&gt;AND ACTV_REASON_CODE = 'R' &lt;BR /&gt;AND FEATURE_CODE = 'STD'&lt;BR /&gt;GROUP BY soc, ban, subscriber_no, feature_code, actv_amt;&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;BR /&gt;CREATE TABLE work.mobpp3 AS&lt;BR /&gt;SELECT t1.soc, t1.ban, t1.subscriber_no, t2.feature_code, t2.soc_price&lt;BR /&gt;FROM work.mobpp1 t1, work.mobpp2 t2&lt;BR /&gt;WHERE t1.ban = t2.ban&lt;BR /&gt;AND t1.subscriber_no = t2.subscriber_no;&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;BR /&gt;CREATE TABLE work.mobpp4 AS&lt;BR /&gt;SELECT DISTINCT ban, account_type, account_sub_type&lt;BR /&gt;FROM bmlappo.billing_account;&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;BR /&gt;CREATE TABLE work.mobpp5 AS&lt;BR /&gt;SELECT t1.*, t2.account_type, t2.account_sub_type&lt;BR /&gt;FROM work.mobpp3 t1, work.mobpp4 t2&lt;BR /&gt;WHERE t1.ban = t2.ban;&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;PROC SQL;&lt;BR /&gt;CREATE TABLE work.mobpp6 AS&lt;BR /&gt;SELECT DISTINCT soc, soc_description, service_type, soc_status, datepart (sale_eff_date)format=mmddyy10. AS sale_eff_date, datepart(sale_exp_date)format=mmddyy10. AS sale_exp_date, product_type&lt;BR /&gt;FROM bmlrwork.soc&lt;BR /&gt;WHERE (expiration_date IS NULL OR expiration_date&amp;nbsp; &amp;gt;= '15-DEC-2014'd)&lt;BR /&gt;AND product_type IN ('CEL','A');&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;BR /&gt;CREATE TABLE work.mobpp7 AS&lt;BR /&gt;SELECT t1.*, t2.soc_description, t2.service_type, t2.soc_status, t2.sale_eff_date, t2.sale_exp_date&lt;BR /&gt;FROM work.mobpp5 t1, work.mobpp6 t2&lt;BR /&gt;GROUP BY soc, feature, ban;&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 17 Dec 2014 19:09:42 GMT</pubDate>
    <dc:creator>Giuliano</dc:creator>
    <dc:date>2014-12-17T19:09:42Z</dc:date>
    <item>
      <title>How to add a %Let Statement to my code?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-Let-Statement-to-my-code/m-p/154305#M30271</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am new to SAS and I am creating a program to compare pricing month over month for the variable "SOC".&amp;nbsp; The code I have so far is below.&amp;nbsp; I need to add a %Let macro statement to the code below so I can enter the month I am looking up.&amp;nbsp; Any help would be appreciated.&amp;nbsp; I am not sure how to do this or where in the code to add it.&amp;nbsp; I am also tring to ensure I do not have any duplicate "SOC" variables.&amp;nbsp; Not sure if using the DISTINCT function will work.&amp;nbsp; I am pulling necessary information from several tables and joining them.&amp;nbsp; Now I need a way to automate this program so it can run it month over month.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;BR /&gt;CREATE TABLE work.mobpp1 AS&lt;BR /&gt;SELECT DISTINCT soc, ban, subscriber_no &lt;BR /&gt;FROM bmlappo.service_agreement&lt;BR /&gt;WHERE subscriber_no ~= '0000000000'&lt;BR /&gt;AND expiration_date IS NULL OR expiration_date&amp;nbsp; &amp;gt;= '15-DEC-2014'd&lt;BR /&gt;GROUP BY soc, ban, subscriber_no;&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;CREATE TABLE work.mobpp2 AS&lt;BR /&gt;SELECT DISTINCT soc, ban, subscriber_no, feature_code, SUM (ACTV_AMT) AS soc_price&lt;BR /&gt;FROM bmlappo.charge&lt;BR /&gt;WHERE sys_creation_date &amp;gt;= '15-DEC-2014'd&lt;BR /&gt;AND ACTV_REASON_CODE = 'R' &lt;BR /&gt;AND FEATURE_CODE = 'STD'&lt;BR /&gt;GROUP BY soc, ban, subscriber_no, feature_code, actv_amt;&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;BR /&gt;CREATE TABLE work.mobpp3 AS&lt;BR /&gt;SELECT t1.soc, t1.ban, t1.subscriber_no, t2.feature_code, t2.soc_price&lt;BR /&gt;FROM work.mobpp1 t1, work.mobpp2 t2&lt;BR /&gt;WHERE t1.ban = t2.ban&lt;BR /&gt;AND t1.subscriber_no = t2.subscriber_no;&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;BR /&gt;CREATE TABLE work.mobpp4 AS&lt;BR /&gt;SELECT DISTINCT ban, account_type, account_sub_type&lt;BR /&gt;FROM bmlappo.billing_account;&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;BR /&gt;CREATE TABLE work.mobpp5 AS&lt;BR /&gt;SELECT t1.*, t2.account_type, t2.account_sub_type&lt;BR /&gt;FROM work.mobpp3 t1, work.mobpp4 t2&lt;BR /&gt;WHERE t1.ban = t2.ban;&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;PROC SQL;&lt;BR /&gt;CREATE TABLE work.mobpp6 AS&lt;BR /&gt;SELECT DISTINCT soc, soc_description, service_type, soc_status, datepart (sale_eff_date)format=mmddyy10. AS sale_eff_date, datepart(sale_exp_date)format=mmddyy10. AS sale_exp_date, product_type&lt;BR /&gt;FROM bmlrwork.soc&lt;BR /&gt;WHERE (expiration_date IS NULL OR expiration_date&amp;nbsp; &amp;gt;= '15-DEC-2014'd)&lt;BR /&gt;AND product_type IN ('CEL','A');&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;BR /&gt;CREATE TABLE work.mobpp7 AS&lt;BR /&gt;SELECT t1.*, t2.soc_description, t2.service_type, t2.soc_status, t2.sale_eff_date, t2.sale_exp_date&lt;BR /&gt;FROM work.mobpp5 t1, work.mobpp6 t2&lt;BR /&gt;GROUP BY soc, feature, ban;&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Dec 2014 19:09:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-Let-Statement-to-my-code/m-p/154305#M30271</guid>
      <dc:creator>Giuliano</dc:creator>
      <dc:date>2014-12-17T19:09:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a %Let Statement to my code?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-Let-Statement-to-my-code/m-p/154306#M30272</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;STRONG&gt;&lt;A _jive_internal="true" class="jiveTT-hover-user jive-username-link active_link" data-avatarid="-1" data-externalid="" data-presence="null" data-userid="858555" data-username="Giuliano" href="https://communities.sas.com/people/Giuliano" id="jive-85855534224285529825186" style="padding: 0px 3px 0px 0px; color: #0e66ba; font-family: inherit; font-size: 1.1em; font-style: inherit; font-weight: inherit;"&gt;Giuliano&lt;/A&gt;&lt;/STRONG&gt;,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Welcome to Communities on SAS. Glad you are here.&lt;/P&gt;&lt;P&gt;I am going to move your question to the Macro group so you have a better chance of getting your question seen and answered. Be sure to mark it "answered" or "helpful answer" if someone replies. Thank so much!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Dec 2014 19:27:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-Let-Statement-to-my-code/m-p/154306#M30272</guid>
      <dc:creator>Community_Help</dc:creator>
      <dc:date>2014-12-17T19:27:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a %Let Statement to my code?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-Let-Statement-to-my-code/m-p/154307#M30273</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Add it at the top.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let month=DEC;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then find wherever DEC is in your code and replace it with &amp;amp;month. Make sure that if it's in quotes, its in double quotes not single quotes.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Dec 2014 19:40:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-Let-Statement-to-my-code/m-p/154307#M30273</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-12-17T19:40:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a %Let Statement to my code?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-Let-Statement-to-my-code/m-p/154308#M30274</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Given that you are relatively new to SAS, I would recommend a two-step, keep-it-simple approach.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Step 1 may already be complete:&amp;nbsp; Get a version of your code that works for one particular date with no macro language.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Step 2 adds macro language, but in the simplest way possible.&amp;nbsp; Use a %LET statement that assigns the entire date string, such as:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let mydate = '15-DEC-2014'd;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then within your code replace all occurrences of '15-DEC-2014'd with &amp;amp;mydate.&amp;nbsp; That combination will perform simple text substitution wherever &amp;amp;mydate appears.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Dec 2014 19:53:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-Let-Statement-to-my-code/m-p/154308#M30274</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2014-12-17T19:53:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a %Let Statement to my code?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-Let-Statement-to-my-code/m-p/154309#M30275</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for help!&amp;nbsp; Much appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Dec 2014 19:59:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-Let-Statement-to-my-code/m-p/154309#M30275</guid>
      <dc:creator>Giuliano</dc:creator>
      <dc:date>2014-12-17T19:59:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a %Let Statement to my code?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-Let-Statement-to-my-code/m-p/154310#M30276</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you, that's help me a great deal.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Dec 2014 20:00:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-Let-Statement-to-my-code/m-p/154310#M30276</guid>
      <dc:creator>Giuliano</dc:creator>
      <dc:date>2014-12-17T20:00:27Z</dc:date>
    </item>
  </channel>
</rss>

