<?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: Regarding codition in SAS EG in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Regarding-codition-in-SAS-EG/m-p/468640#M30400</link>
    <description>&lt;P&gt;At a guess (post test data in the form of a datastep, and show your code and required output):&lt;/P&gt;
&lt;PRE&gt;data want;
  set have;
  if input("&amp;amp;max_uwy.",best.)=uwy and lag(uwy ne input("&amp;amp;max_uwy.",best.)-1) then status="New";
  else if input("&amp;amp;max_uwy.",best.)=uwy then status="Renew";
run;&lt;/PRE&gt;</description>
    <pubDate>Fri, 08 Jun 2018 10:06:06 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2018-06-08T10:06:06Z</dc:date>
    <item>
      <title>Regarding codition in SAS EG</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Regarding-codition-in-SAS-EG/m-p/468634#M30398</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have one scenario&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is one small dataset&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;BUS_ID&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;UWY&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;Status&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;A1008067&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2010&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;A1007937&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2015&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;A1009536&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2012&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;A1005405&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2013&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;A1008311&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2018&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;A1009536&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2005&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;A1005502&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2001&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;A1005524&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2000&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;A1008067&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;1998&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We have three columns, Business_ID(BUS_ID), Under_Writting_Year(UWY) and last column as Status.&lt;/P&gt;&lt;P&gt;Suppose I am using one parameter to run the report containing this dataset. That parameter is UWY. That parameter has two value &amp;amp;max_uwy and &amp;amp;min_uwy.&lt;/P&gt;&lt;P&gt;Suppose one BUS_ID is in the &amp;amp;max_uwy&amp;nbsp; available but not available in the &amp;amp;min_uwy, it means it is new, not repeating, then the status column will be "New" or else it will be "Renew"&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;&lt;FONT face="Arial"&gt;if the&amp;nbsp; report was run of UWY 2017, if this (Business ID),&amp;nbsp; has no records in UW 2016 , then the Status is “&lt;/FONT&gt;&lt;SPAN&gt;New&lt;/SPAN&gt;&lt;SPAN&gt;”, else its “&lt;/SPAN&gt;&lt;SPAN&gt;Renew&lt;/SPAN&gt;&lt;SPAN&gt;” &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope I am able to make you understand.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help me to solve the issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let me know any doubt there.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jun 2018 09:33:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Regarding-codition-in-SAS-EG/m-p/468634#M30398</guid>
      <dc:creator>Sourav_sas</dc:creator>
      <dc:date>2018-06-08T09:33:22Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding codition in SAS EG</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Regarding-codition-in-SAS-EG/m-p/468640#M30400</link>
      <description>&lt;P&gt;At a guess (post test data in the form of a datastep, and show your code and required output):&lt;/P&gt;
&lt;PRE&gt;data want;
  set have;
  if input("&amp;amp;max_uwy.",best.)=uwy and lag(uwy ne input("&amp;amp;max_uwy.",best.)-1) then status="New";
  else if input("&amp;amp;max_uwy.",best.)=uwy then status="Renew";
run;&lt;/PRE&gt;</description>
      <pubDate>Fri, 08 Jun 2018 10:06:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Regarding-codition-in-SAS-EG/m-p/468640#M30400</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-06-08T10:06:06Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding codition in SAS EG</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Regarding-codition-in-SAS-EG/m-p/468918#M30417</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your reply. I have attached one screenshot of sample dataset. with that can you try this scenario. and explained one prompt also. That is uwy. This prompt type should be like&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.JPG" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/21122i751202A1885AF6A1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Capture.JPG" alt="Capture.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;For that I have given the example. &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000" face="Arial"&gt;&amp;nbsp;if the&amp;nbsp; report was run of UW&amp;nbsp; year 2017, if this contract (Business ID),&amp;nbsp; has no records in UW 2016 , then the Contract is "New" else this is "Renew". &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000" face="Arial"&gt;I have one sample code that is I am taking from my production code....&lt;/FONT&gt;&lt;/P&gt;&lt;PRE&gt;&lt;FONT color="#000000" face="Arial"&gt;&lt;CODE class=" language-sas"&gt;proc sql;
	create table work.out as
		select 
			t1.BUS_ID,
			t1.UWYEAR ,
			if input("&amp;amp;uwy_max.",best.)=uwy and lag(uwy ne input("&amp;amp;max_uwy.",best.)-1) 
			then status="New";
  			else if input("&amp;amp;max_uwy.",best.)=uwy then status="Renew";

		from work.dummydata t1
		where 
		%STP_WHERE_PARAM(t1.BUS_ID,bus_id,IN, TYPE=S)
				and &amp;amp;UWY_MN. &amp;lt;= t1.UWYEAR &amp;lt;= &amp;amp;UWY_MX.
			order by BASE_COMPANY_TITLE,
				BUS_ID,
				UWYEAR
	;
quit;&lt;/CODE&gt;&lt;/FONT&gt;&lt;/PRE&gt;&lt;P&gt;&lt;FONT color="#000000" face="Arial"&gt;Here I have used only two columns (BUS_ID and UWY) these both are available in that sample dataset which I have shared on my first post. Here I have used two prompts, BUS_ID and UWY. For STP prompt creation we use DI Studio and we have some defined macro for prompt calling, like %STP_WHERE_PARAM. &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000" face="Arial"&gt;&amp;amp;UWY_MIN and &amp;amp;UWY_MX these part of prompt. bus_id also one prompt. bus_id is dynamic selection prompt, and uwy is range type prompt. &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000" face="Arial"&gt;Here I want add one column that is Status. For status condition as discussed earlier like,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000" face="Arial"&gt;If I ma selecting 2017 as UWY and before that in 2016 no BUS_ID is available, it means that BUS_ID is new, for that we will have status as "NEW", and if we have the same BUS_ID in 2016, it means it is not new, it is repeating, then the status would be "Renew".&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000" face="Arial"&gt;I hope I am able to make you understand. &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000" face="Arial"&gt;Can any one help me to create this condition. Its bit urgent.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000" face="Arial"&gt;Regards&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000" face="Arial"&gt;Sourav&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 09 Jun 2018 07:44:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Regarding-codition-in-SAS-EG/m-p/468918#M30417</guid>
      <dc:creator>Sourav_sas</dc:creator>
      <dc:date>2018-06-09T07:44:22Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding codition in SAS EG</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Regarding-codition-in-SAS-EG/m-p/468934#M30418</link>
      <description>&lt;P&gt;Hi ca anyone give a suitable solution for this.&amp;nbsp; I really need for one project.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 09 Jun 2018 14:29:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Regarding-codition-in-SAS-EG/m-p/468934#M30418</guid>
      <dc:creator>Sourav_sas</dc:creator>
      <dc:date>2018-06-09T14:29:29Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding codition in SAS EG</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Regarding-codition-in-SAS-EG/m-p/469141#M30420</link>
      <description>&lt;P&gt;Why not do it in several steps?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First create a table with min/max of UWY for each busid&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then lef join that table on your data and check if min/max to see if its new or not.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Something like this: If (missing(UWY) or max(min,max) = UWY) then new else renew.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;//Fredrik&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jun 2018 08:52:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Regarding-codition-in-SAS-EG/m-p/469141#M30420</guid>
      <dc:creator>FredrikE</dc:creator>
      <dc:date>2018-06-11T08:52:50Z</dc:date>
    </item>
  </channel>
</rss>

