<?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: Can someone sense check my code please in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Can-someone-sense-check-my-code-please/m-p/197844#M266564</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The issue im having is how to write the code correctly for the sums and case statements. Im trying to replicate what has been completed within excel and the formulas used. Excel was used as a test so we knew what we needed to do within SAS but im finding it tricky in completing the code. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 08 Jul 2015 09:27:42 GMT</pubDate>
    <dc:creator>anonymous_user</dc:creator>
    <dc:date>2015-07-08T09:27:42Z</dc:date>
    <item>
      <title>Can someone sense check my code please</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-someone-sense-check-my-code-please/m-p/197841#M266561</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have the following code but I can't seem to get it to work. I have a feeling the case statements are wrong but unsure what the issues are.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What im trying to do is upload 4 tabs from a CSV file and create a table within SAS. I then need a statement to bring back the variables and calculations.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro Import(path = ,outputdataset = , sheetname = );&lt;BR /&gt;proc import datafile = "&amp;amp;path" out = &amp;amp;outputdataset dbms=excel replace;&lt;BR /&gt;sheet = "&amp;amp;sheetname";&lt;BR /&gt;run;&lt;BR /&gt;%mend;&lt;BR /&gt;%import(path= 'Mortgage finance\a&amp;amp;tp\DM\CRDM Flow Model\CRDM Flow Model.xls'outputdataset = tab1 ,sheetname =BO data – Allocations)&lt;BR /&gt;%import(path= 'Mortgage finance\a&amp;amp;tp\DM\CRDM Flow Model\CRDM Flow Model.xls'outputdataset = tab2 ,sheetname =BO data – Completions)&lt;BR /&gt;%import(path= 'Mortgage finance\a&amp;amp;tp\DM\CRDM Flow Model\CRDM Flow Model.xls'outputdataset = tab3 ,sheetname =Hedging Assumptions 1)&lt;BR /&gt;%import(path= 'Mortgage finance\a&amp;amp;tp\DM\CRDM Flow Model\CRDM Flow Model.xls'outputdataset = tab4 ,sheetname =Hedging Assumptions 2)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Proc sql;&lt;BR /&gt;Create table work.steve as &lt;BR /&gt;select &lt;BR /&gt;Product_End_Date as Product_end_date,&lt;BR /&gt;Term as Term,&lt;BR /&gt;Launch_Code as launch_code,&lt;BR /&gt;Weekly_Movement_Allocs as Weekly_movement_Allocs&lt;BR /&gt;LTD_Pipeline as Pipeline_ytd,&lt;BR /&gt;LTD_Completions as Completions_ytd,&lt;BR /&gt;CATX(",", product_end_date, term, launchcode)as Date_Term_Prod,&lt;BR /&gt;Term_hedge_2 as Term_hedge_2 ,&lt;BR /&gt;Prepayment_rate_hedge_2 as Prepayment_rate_hedge_2,&lt;BR /&gt;Conversion_Rate_hedge as Conversion_Rate_hedge,&lt;BR /&gt;Key_hedge as Key_hedge,&lt;BR /&gt;Product_Term_comps as Product_Term_comps,&lt;/P&gt;&lt;P&gt;case when Date_Term_Prod = Key_hedge then Conversion_Rate_hedge else 0 end as Alco_pc,&lt;BR /&gt;Case when Product_Term_comps = Term_hedge_2 then Prepayment_rate_hedge_2 else 0 end as prepayment,&lt;BR /&gt;case when alco_pc = 0 then Pipeline_ytd, Pipeline_ytd*alco_pc end as pipeline_x_alco_pc,&lt;BR /&gt;sum(case when pipeline_x_alco_pc + Completions_ytd * prepayment) as LTD,&lt;BR /&gt;case when Product_end_date = 0 then sum(Weekly_movement_Allocs * prepayment) else sum(Weekly_movement_Allocs * Alco_pc * prepayment) as weekly_movement&lt;/P&gt;&lt;P&gt;From Hedging_Dataset;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table work.steve2 as &lt;BR /&gt;select &lt;BR /&gt;Product_Term_comps,&lt;BR /&gt;Pipeline_ytd,&lt;BR /&gt;alco_pc,&lt;BR /&gt;pipeline_x_alco_pc,&lt;BR /&gt;Completions_ytd,&lt;BR /&gt;prepayment,&lt;BR /&gt;LTD,&lt;BR /&gt;weekly_movement&lt;/P&gt;&lt;P&gt;from &lt;BR /&gt;work.steve;&lt;BR /&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Jul 2015 08:44:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-someone-sense-check-my-code-please/m-p/197841#M266561</guid>
      <dc:creator>anonymous_user</dc:creator>
      <dc:date>2015-07-08T08:44:05Z</dc:date>
    </item>
    <item>
      <title>Re: Can someone sense check my code please</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-someone-sense-check-my-code-please/m-p/197842#M266562</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;Put a comma before ouputdataset in the macro call&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;else try this &lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;%import(path= %nrstr(Mortgage finance\a&amp;amp;tp\DM\CRDM Flow Model\CRDM Flow Model.xls),outputdataset = tab1 ,sheetname =%str(BO data – Allocations));&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Jul 2015 09:04:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-someone-sense-check-my-code-please/m-p/197842#M266562</guid>
      <dc:creator>MadhuKorni</dc:creator>
      <dc:date>2015-07-08T09:04:37Z</dc:date>
    </item>
    <item>
      <title>Re: Can someone sense check my code please</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-someone-sense-check-my-code-please/m-p/197843#M266563</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well, market rate is a bout 60euro an hour...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Some pointers.&amp;nbsp; First your not using CSV, your using Excel file format.&amp;nbsp; I will point out that this is not a good idea, Excel is not a data transfer format, it doesn't have strcuture like proper data.&amp;nbsp; Anyways, however you get the data in, I could not see the tab datasets created by the macro used anywhere or combined?&amp;nbsp; Secondly format the code in a readable way, use indents, consitent casing, split case statements over rows.&amp;nbsp; E.g.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; case&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when &amp;lt;condition&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; then &amp;lt;value&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when &amp;lt;condition&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; then &amp;lt;value&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else &amp;lt;value&amp;gt; end as &amp;lt;variable&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You use sums() in your code, but I don't see any grouping.&lt;/P&gt;&lt;P&gt;You are missing a space before the as in: &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;CATX(",", product_end_date, term, launchcode)as Date_Term_Prod,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;This code is illogical: &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;sum(case when pipeline_x_alco_pc + Completions_ytd * prepayment) as LTD,&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;There is no else or end for the case, and why bother putting case statements in a sum()?&lt;/SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As for your question, "&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt; I have a feeling the case statements are wrong but unsure what the issues are.", in what way are they wrong, other than maybe some typos I can't&amp;nbsp; guess what you trying to achieve.&amp;nbsp; I assume that your code will be validated by a second person, who will have a spec available, so they would be able to check any logical issues.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Jul 2015 09:09:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-someone-sense-check-my-code-please/m-p/197843#M266563</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-07-08T09:09:04Z</dc:date>
    </item>
    <item>
      <title>Re: Can someone sense check my code please</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-someone-sense-check-my-code-please/m-p/197844#M266564</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The issue im having is how to write the code correctly for the sums and case statements. Im trying to replicate what has been completed within excel and the formulas used. Excel was used as a test so we knew what we needed to do within SAS but im finding it tricky in completing the code. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Jul 2015 09:27:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-someone-sense-check-my-code-please/m-p/197844#M266564</guid>
      <dc:creator>anonymous_user</dc:creator>
      <dc:date>2015-07-08T09:27:42Z</dc:date>
    </item>
  </channel>
</rss>

