<?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: USING RETAIN STATEMENT IN PROC SQL in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/USING-RETAIN-STATEMENT-IN-PROC-SQL/m-p/312544#M67815</link>
    <description>&lt;P&gt;If you had taken the time to read the &lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000214163.htm" target="_blank"&gt;documentation&lt;/A&gt;, you would not have posted this question.&lt;/P&gt;
&lt;P&gt;Quote from there:&lt;/P&gt;
&lt;P&gt;Valid: in a DATA step&lt;/P&gt;</description>
    <pubDate>Fri, 18 Nov 2016 08:13:42 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2016-11-18T08:13:42Z</dc:date>
    <item>
      <title>USING RETAIN STATEMENT IN PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/USING-RETAIN-STATEMENT-IN-PROC-SQL/m-p/312539#M67813</link>
      <description>&lt;P&gt;Hello Everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could any one help me out how to retain a variable in Proc SQL like how we do in Base SAS.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;syntax please....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Geetha.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Nov 2016 07:57:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/USING-RETAIN-STATEMENT-IN-PROC-SQL/m-p/312539#M67813</guid>
      <dc:creator>GeethaMN</dc:creator>
      <dc:date>2016-11-18T07:57:52Z</dc:date>
    </item>
    <item>
      <title>Re: USING RETAIN STATEMENT IN PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/USING-RETAIN-STATEMENT-IN-PROC-SQL/m-p/312540#M67814</link>
      <description>&lt;P&gt;You can't use retain or anything similar in PROC SQL AFAIK.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please explain what you're trying to do in detail and maybe we can offer alternate solutions.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Nov 2016 08:02:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/USING-RETAIN-STATEMENT-IN-PROC-SQL/m-p/312540#M67814</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-11-18T08:02:06Z</dc:date>
    </item>
    <item>
      <title>Re: USING RETAIN STATEMENT IN PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/USING-RETAIN-STATEMENT-IN-PROC-SQL/m-p/312544#M67815</link>
      <description>&lt;P&gt;If you had taken the time to read the &lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000214163.htm" target="_blank"&gt;documentation&lt;/A&gt;, you would not have posted this question.&lt;/P&gt;
&lt;P&gt;Quote from there:&lt;/P&gt;
&lt;P&gt;Valid: in a DATA step&lt;/P&gt;</description>
      <pubDate>Fri, 18 Nov 2016 08:13:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/USING-RETAIN-STATEMENT-IN-PROC-SQL/m-p/312544#M67815</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-11-18T08:13:42Z</dc:date>
    </item>
    <item>
      <title>Re: USING RETAIN STATEMENT IN PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/USING-RETAIN-STATEMENT-IN-PROC-SQL/m-p/312555#M67818</link>
      <description>&lt;P&gt;Retain is irrelevant in terms of SQL. &amp;nbsp;Remember the two are different languages with their own ways of thinking. &amp;nbsp;When designing an SQL step, you select the variables you wish to keep, then specify from/how. &amp;nbsp;Do not fall into the trap of being a lazy programmer and doing:&lt;/P&gt;
&lt;P&gt;select *&lt;/P&gt;
&lt;P&gt;Take those extra few seconds to type in (or if your lucky enough to have a proper ide, copy/paste from object viewer) exactly what data you need.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Nov 2016 09:17:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/USING-RETAIN-STATEMENT-IN-PROC-SQL/m-p/312555#M67818</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-11-18T09:17:59Z</dc:date>
    </item>
    <item>
      <title>Re: USING RETAIN STATEMENT IN PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/USING-RETAIN-STATEMENT-IN-PROC-SQL/m-p/312604#M67825</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
	create table VS_der as 
		select *, catx('-',STUDYID,SUBJID,SITEID) as USUBJID,
		       (case
               when upcase(visit) ne 'UNSCHEDULED' then VISITN
			   else VISITN+0.1
			   end) as AVISITN
			from vs;
quit;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/5898iABCD71FA6BCE0366/image-size/original?v=v2&amp;amp;px=-1" border="0" alt="visitinfo.png" title="visitinfo.png" width="491" height="274" /&gt;&lt;/P&gt;&lt;P&gt;I agree with you Kurt it is valid for only data step. but when am doing the above step, wherever the visit ne 'unscheduled' i want to have avisitn value should be previous value+0.1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;for ex., at 7th observation the value should not be 999.1 it should be 6.1 and the same way at 15th and 16th observation it should be 5.1,5.2.. that is my requirement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so, i thought of is there any chance of doing retaining avisitn variable in proc sql.. &amp;nbsp;actually in sql we can able to retain a variable by declare .. but how we can do in proc sql??&lt;/P&gt;</description>
      <pubDate>Fri, 18 Nov 2016 12:51:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/USING-RETAIN-STATEMENT-IN-PROC-SQL/m-p/312604#M67825</guid>
      <dc:creator>GeethaMN</dc:creator>
      <dc:date>2016-11-18T12:51:27Z</dc:date>
    </item>
    <item>
      <title>Re: USING RETAIN STATEMENT IN PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/USING-RETAIN-STATEMENT-IN-PROC-SQL/m-p/312606#M67826</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data vs_der;
set vs;
oldvisitn = lag(visitn);
if upcase(visit) = 'UNSCHEDULED' then visitn = oldvisitn + .1;
drop oldvisitn;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here the data step really comes into its own, as it provides functionality that is quite complicated to build in SQL.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit: changed dataset names.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Nov 2016 12:58:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/USING-RETAIN-STATEMENT-IN-PROC-SQL/m-p/312606#M67826</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-11-18T12:58:34Z</dc:date>
    </item>
  </channel>
</rss>

