<?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: Bad in the next 12 months flag in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Bad-in-the-next-12-months-flag/m-p/550372#M152808</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;A id="link_8" class="lia-link-navigation lia-page-link lia-user-name-link" href="https://communities.sas.com/t5/user/viewprofilepage/user-id/130614" target="_self"&gt;&lt;SPAN class=""&gt;Adnan_Razaq&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could use the &lt;A href="https://go.documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lestmtsref&amp;amp;docsetTarget=p00hxg3x8lwivcn1f0e9axziw57y.htm&amp;amp;locale=en#n19qtk2v7izsqen1n0am0e5wq268" target="_blank" rel="noopener"&gt;point set statement option&lt;/A&gt; to process the dataset (see below)&lt;BR /&gt;Be warned &lt;SPAN&gt;Continuous loops can occur when you use the POINT= option.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
	/* Read the Dataset to determine number of observations (nobs set statement option) */
	set have nobs=numberObs ;
	/* Set up a loop (i) to process all the observations in the dataset */
	do i=1 to numberObs ;
		/* variable to point 12 observations ahead */
		plus12=i+12 ;
		/* Only look ahead when there are 12 more observations in the dataset */
		if plus12&amp;lt;=numberObs then do ;
			/* Read the bad_flag for the 12th observation ahead of the current observation */
			/* rename bad_flag to bad_flag_in12 */
			set have(keep=bad_flag rename=(bad_flag=bad_flag_in12)) point=plus12 ;
		end ;
		/* Read the current observation */
		set have point=i  ;
		/* If current observation bad_flag=1 then force bad_flag_in12=0 */
		if bad_flag=1 then
			bad_flag_in12=0 ;
		output want ;
	end ;
	/* Stop processing - Otherwise this will loop */
	stop ;
run ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 11 Apr 2019 19:06:32 GMT</pubDate>
    <dc:creator>AMSAS</dc:creator>
    <dc:date>2019-04-11T19:06:32Z</dc:date>
    <item>
      <title>Bad in the next 12 months flag</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Bad-in-the-next-12-months-flag/m-p/550230#M152755</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the a smilar dataset as below consisting multiple account numbers and reporting months and would like to calculate the bad in the next 12 months flag using the value bad flag.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;

input Acc Date $ Bad_Flag;

datalines;

 

1 Jan2018 0

1 Feb2018 0

1 Mar2018 0

1 Apr2018 0

1 May2018 0

1 Jun2018 0

1 Jul2018 0

1 Aug2018 0

1 Sep2018 0

1 Oct2018 0

1 Nov2018 0

1 Dec2018 0

1 Jan2019 0

1 Feb2019 0

1 Mar2019 0

1 Apr2019 1

1 May2019 1

1 Jun2019 1

1 Jul2019 1

1 Aug2019 1

1 Sep2019 1

1 Oct2019 1

1 Nov2019 1

1 Dec2019 1

;

run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to create a new varaiable&amp;nbsp; which will be set to 1 if there's is a bad flag from 12 months from the reporting month. For the example above the bad in next 12 months flag will be 0 until Apr 2018 and then will be 1 going forward until the bad flag is dropped 12 months ahead since there's a bad flag in Apr 2019.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Adnan&lt;/P&gt;</description>
      <pubDate>Thu, 11 Apr 2019 13:39:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Bad-in-the-next-12-months-flag/m-p/550230#M152755</guid>
      <dc:creator>Adnan_Razaq</dc:creator>
      <dc:date>2019-04-11T13:39:07Z</dc:date>
    </item>
    <item>
      <title>Re: Bad in the next 12 months flag</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Bad-in-the-next-12-months-flag/m-p/550292#M152768</link>
      <description>&lt;P&gt;I would do:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want1;
set have;
date12mn= intnx('month', date, 12);
run;

proc sql;
create table want2
as select a.acc, a.date, a.date12mn, a.bad_flag, b.bad_flag as bad_flag12mn
from want1 a
left join want1 b
on a.acc=b.acc and a.date=b.date12mn;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 Apr 2019 15:47:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Bad-in-the-next-12-months-flag/m-p/550292#M152768</guid>
      <dc:creator>Tommy1</dc:creator>
      <dc:date>2019-04-11T15:47:02Z</dc:date>
    </item>
    <item>
      <title>Re: Bad in the next 12 months flag</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Bad-in-the-next-12-months-flag/m-p/550302#M152775</link>
      <description>It might be a.date12mn=b.date I can't remember</description>
      <pubDate>Thu, 11 Apr 2019 15:49:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Bad-in-the-next-12-months-flag/m-p/550302#M152775</guid>
      <dc:creator>Tommy1</dc:creator>
      <dc:date>2019-04-11T15:49:41Z</dc:date>
    </item>
    <item>
      <title>Re: Bad in the next 12 months flag</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Bad-in-the-next-12-months-flag/m-p/550372#M152808</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;A id="link_8" class="lia-link-navigation lia-page-link lia-user-name-link" href="https://communities.sas.com/t5/user/viewprofilepage/user-id/130614" target="_self"&gt;&lt;SPAN class=""&gt;Adnan_Razaq&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could use the &lt;A href="https://go.documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lestmtsref&amp;amp;docsetTarget=p00hxg3x8lwivcn1f0e9axziw57y.htm&amp;amp;locale=en#n19qtk2v7izsqen1n0am0e5wq268" target="_blank" rel="noopener"&gt;point set statement option&lt;/A&gt; to process the dataset (see below)&lt;BR /&gt;Be warned &lt;SPAN&gt;Continuous loops can occur when you use the POINT= option.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
	/* Read the Dataset to determine number of observations (nobs set statement option) */
	set have nobs=numberObs ;
	/* Set up a loop (i) to process all the observations in the dataset */
	do i=1 to numberObs ;
		/* variable to point 12 observations ahead */
		plus12=i+12 ;
		/* Only look ahead when there are 12 more observations in the dataset */
		if plus12&amp;lt;=numberObs then do ;
			/* Read the bad_flag for the 12th observation ahead of the current observation */
			/* rename bad_flag to bad_flag_in12 */
			set have(keep=bad_flag rename=(bad_flag=bad_flag_in12)) point=plus12 ;
		end ;
		/* Read the current observation */
		set have point=i  ;
		/* If current observation bad_flag=1 then force bad_flag_in12=0 */
		if bad_flag=1 then
			bad_flag_in12=0 ;
		output want ;
	end ;
	/* Stop processing - Otherwise this will loop */
	stop ;
run ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 Apr 2019 19:06:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Bad-in-the-next-12-months-flag/m-p/550372#M152808</guid>
      <dc:creator>AMSAS</dc:creator>
      <dc:date>2019-04-11T19:06:32Z</dc:date>
    </item>
  </channel>
</rss>

