<?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: Identify change in income source in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Identify-change-in-income-source/m-p/908797#M358575</link>
    <description>&lt;P&gt;"&lt;SPAN&gt;IF there is an income source that was "active" in first 6 months and stopped be "active" in last 6&amp;nbsp; months&lt;/SPAN&gt;"&lt;/P&gt;
&lt;P&gt;So you're not interested in a change where a source was inactive in the first 6 months and then active afterwards?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is your real data also already sorted by cust_id and&amp;nbsp;month_YYYYMM?&lt;/P&gt;
&lt;P&gt;Does your real data also only contain 12 months per customer?&lt;/P&gt;</description>
    <pubDate>Tue, 19 Dec 2023 12:51:32 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2023-12-19T12:51:32Z</dc:date>
    <item>
      <title>Identify change in income source</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-change-in-income-source/m-p/908786#M358574</link>
      <description>Hello&lt;BR /&gt;I have a data set with information of income sources for each customer for 12 months.&lt;BR /&gt;There can be several type of incomes sources:&lt;BR /&gt;Ind_Cash_Deposit(Income from cash deposit)&lt;BR /&gt;Ind_Check_Deposit(Income from cheque deposit)&lt;BR /&gt;Ind_Wage_Income((Income from wage)&lt;BR /&gt;Ind_SocialSeurity_Income(Income from social security)&lt;BR /&gt;I want to check for each customer-&lt;BR /&gt;IF there is an income source that was "active" in first 6 months and stopped be "active" in last 6&amp;amp;nbsp; months.&lt;BR /&gt;The definition of&amp;amp;nbsp; "Active" is that it is used at least 4 months from 6 months.&lt;BR /&gt;For example:&lt;BR /&gt;Customer 111:&lt;BR /&gt;In First 6 months active income sources are- Wage&lt;BR /&gt;In last 6 months active income sources are- Nothing&lt;BR /&gt;So in result wanted field will write "Wage"&lt;BR /&gt;Customer 222:&lt;BR /&gt;In First 6 months active income sources are- Wage+Social Insurance&amp;amp;nbsp;&lt;BR /&gt;In last 6 months active income sources are- Social Insurance&amp;amp;nbsp;&lt;BR /&gt;So in result wanted field will write " Social "&lt;BR /&gt;Customer 333:&lt;BR /&gt;In First 6 months active income sources are- Wage&amp;amp;nbsp;&lt;BR /&gt;In last 6 months active income sources are- Wage&lt;BR /&gt;So in result wanted field will write " No_Change"&lt;BR /&gt;&amp;amp;nbsp;&lt;BR /&gt;May show code that provide the result data set?&lt;BR /&gt;Please not that in result data set each customer will have one row only with following fields:&lt;BR /&gt;Active_Income_Source_First6Mon&lt;BR /&gt;Active_Income_Source_Last6Mon&lt;BR /&gt;Removed_Income_Sources&lt;BR /&gt;Data have;&lt;BR /&gt;input cust_ID YYMM Ind_Cash_Deposit Ind_Check_Deposit Ind_Wage_Income  Ind_SocialSeurity_Income;&lt;BR /&gt;cards;&lt;BR /&gt;111 2212 0 1 1 0&lt;BR /&gt;111 2301 0 0 1 0&lt;BR /&gt;111 2302 0 0 1 0&lt;BR /&gt;111 2303 1 1 1 0&lt;BR /&gt;111 2304 0 0 1 0&lt;BR /&gt;111 2305 0 0 1 0&lt;BR /&gt;111 2306 0 0 1 0&lt;BR /&gt;111 2307 0 0 1 0&lt;BR /&gt;111 2308 0 0 1 0&lt;BR /&gt;111 2309 0 0 0 0&lt;BR /&gt;111 2310 0 0 0 0&lt;BR /&gt;111 2311 0 0 0 0&lt;BR /&gt;222 2212 0 0 1 1&lt;BR /&gt;222 2301 0 0 1 1&lt;BR /&gt;222 2302 0 0 1 1&lt;BR /&gt;222 2303 0 0 1 1&lt;BR /&gt;222 2304 0 0 1 1&lt;BR /&gt;222 2305 0 0 1 1&lt;BR /&gt;222 2306 0 0 1 1&lt;BR /&gt;222 2307 0 0 1 1&lt;BR /&gt;222 2308 0 0 1 1&lt;BR /&gt;222 2309 0 0 0 1&lt;BR /&gt;222 2310 0 0 0 1&lt;BR /&gt;222 2311 0 0 0 1&lt;BR /&gt;333 2212 0 0 1 0&lt;BR /&gt;333 2301 0 0 1 0&lt;BR /&gt;333 2302 0 0 1 1&lt;BR /&gt;333 2303 0 0 1 1&lt;BR /&gt;333 2304 0 0 1 0&lt;BR /&gt;333 2305 0 0 1 0&lt;BR /&gt;333 2306 0 0 1 0&lt;BR /&gt;333 2307 0 0 1 0&lt;BR /&gt;333 2308 0 0 1 0&lt;BR /&gt;333 2309 0 0 1 0&lt;BR /&gt;333 2310 0 0 1 1&lt;BR /&gt;333 2311 0 0 1 0&lt;BR /&gt;;&lt;BR /&gt;Date=input(cat(YYMM),YYMMN4.):&lt;BR /&gt;Format date date9.;&lt;BR /&gt;Run;</description>
      <pubDate>Tue, 19 Dec 2023 15:04:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-change-in-income-source/m-p/908786#M358574</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2023-12-19T15:04:15Z</dc:date>
    </item>
    <item>
      <title>Re: Identify change in income source</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-change-in-income-source/m-p/908797#M358575</link>
      <description>&lt;P&gt;"&lt;SPAN&gt;IF there is an income source that was "active" in first 6 months and stopped be "active" in last 6&amp;nbsp; months&lt;/SPAN&gt;"&lt;/P&gt;
&lt;P&gt;So you're not interested in a change where a source was inactive in the first 6 months and then active afterwards?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is your real data also already sorted by cust_id and&amp;nbsp;month_YYYYMM?&lt;/P&gt;
&lt;P&gt;Does your real data also only contain 12 months per customer?&lt;/P&gt;</description>
      <pubDate>Tue, 19 Dec 2023 12:51:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-change-in-income-source/m-p/908797#M358575</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-12-19T12:51:32Z</dc:date>
    </item>
    <item>
      <title>Re: Identify change in income source</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-change-in-income-source/m-p/908823#M358577</link>
      <description>Always 12 months follow up for each customer.  If there are added sources of income then put it in plus  for example "wage+". If lost income sources than put it in minus for example  " wage-"</description>
      <pubDate>Tue, 19 Dec 2023 14:58:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-change-in-income-source/m-p/908823#M358577</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2023-12-19T14:58:33Z</dc:date>
    </item>
    <item>
      <title>Re: Identify change in income source</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-change-in-income-source/m-p/908824#M358578</link>
      <description>&lt;P&gt;Yet another case of the first thing needed to deal with "6 months" is fixing the "date" value for every single record.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Repeatedly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are going to ask us about intervals then at least do the step yourself to make sure there is an actual DATE value before asking for help.&lt;/P&gt;
&lt;P&gt;You've been shown how multiple times.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Dec 2023 14:59:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-change-in-income-source/m-p/908824#M358578</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-12-19T14:59:29Z</dc:date>
    </item>
    <item>
      <title>Re: Identify change in income source</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-change-in-income-source/m-p/908961#M358612</link>
      <description>&lt;P&gt;Here is the raw data set.&lt;/P&gt;
&lt;P&gt;I added date var&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data _have;
input cust_ID YYMM Ind_Cash_Deposit Ind_Check_Deposit Ind_Wage_Income Ind_SocialSeurity_Income;
cards;
111 2212 0 1 1 0
111 2301 0 0 1 0
111 2302 0 0 1 0
111 2303 1 1 1 0
111 2304 0 0 1 0
111 2305 0 0 1 0
111 2306 0 0 1 0
111 2307 0 0 1 0
111 2308 0 0 1 0
111 2309 0 0 0 0
111 2310 0 0 0 0
111 2311 0 0 0 0
222 2212 0 0 1 1
222 2301 0 0 1 1
222 2302 0 0 1 1
222 2303 0 0 1 1
222 2304 0 0 1 1
222 2305 0 0 1 1
222 2306 0 0 1 1
222 2307 0 0 1 1
222 2308 0 0 1 1
222 2309 0 0 0 1
222 2310 0 0 0 1
222 2311 0 0 0 1
333 2212 0 0 1 0
333 2301 0 0 1 0
333 2302 0 0 1 1
333 2303 0 0 1 1
333 2304 0 0 1 0
333 2305 0 0 1 0
333 2306 0 0 1 0
333 2307 0 0 1 0
333 2308 0 0 1 0
333 2309 0 0 1 0
333 2310 0 0 1 1
333 2311 0 0 1 0
444 2212 0 0 0 0
444 2301 0 0 0 0
444 2302 0 0 0 0
444 2303 0 0 0 0
444 2304 1 1 0 0
444 2305 0 0 0 0
444 2306 0 0 0 0
444 2307 0 0 1 0
444 2308 0 0 1 0
444 2309 0 0 1 0
444 2310 0 0 1 0
444 2311 0 0 1 0
;
Run;

data have;
retain cust_ID YYMM date Ind_Cash_Deposit Ind_Check_Deposit Ind_Wage_Income Ind_SocialSeurity_Income;
set _have;
Date=input(put(YYMM,4.),yymmn4.);
format date date9.;
Run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 20 Dec 2023 05:28:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-change-in-income-source/m-p/908961#M358612</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2023-12-20T05:28:10Z</dc:date>
    </item>
    <item>
      <title>Re: Identify change in income source</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-change-in-income-source/m-p/910804#M359153</link>
      <description>&lt;P&gt;It still a bit unclear, your example forge" 222 seem inconsistent, shouldn't that be "Wage" in Removed_Income_Sources?&lt;/P&gt;
&lt;P&gt;It wold also have been good if you provided test data for scenarios when more than one type of income was removed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second, I think it is clumsy to have information as concatenated strings in one filed, it makes it pretty seless for anythin else than making list reports.&lt;/P&gt;
&lt;P&gt;That said, I created Removed_Income_Sources in the following code, but created active flags per half year and original field.&lt;/P&gt;
&lt;P&gt;You can create Active_Income_Source_First6Mon and Active_Income_Source_Last6Mon yourself using the same startegy.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
	create table h1_2023 as
		select 
			cust_id, 
			case when sum(Ind_Cash_Deposit) &amp;lt; 4 then 0 else 1 end as Ind_Cash_Deposit_F6M, 
			case when sum(Ind_Check_Deposit) &amp;lt; 4 then 0 else 1 end as Ind_Check_Deposit_F6M, 
			case when sum(Ind_Wage_Income) &amp;lt; 4 then 0 else 1 end as Ind_Wage_Income_F6M, 
			case when sum(Ind_SocialSeurity_Income) &amp;lt; 4 then 0 else 1 end as Ind_SocialSeurity_Income_F6M 
		from have
		where date &amp;lt; '01Jul2023'd
		group by cust_id
;
	create table h2_2023 as
		select 
			cust_id, 
			case when sum(Ind_Cash_Deposit) &amp;lt; 4 then 0 else 1 end as Ind_Cash_Deposit_L6M, 
			case when sum(Ind_Check_Deposit) &amp;lt; 4 then 0 else 1 end as Ind_Check_Deposit_L6M, 
			case when sum(Ind_Wage_Income) &amp;lt; 4 then 0 else 1 end as Ind_Wage_Income_L6M, 
			case when sum(Ind_SocialSeurity_Income) &amp;lt; 4 then 0 else 1 end as Ind_SocialSeurity_Income_L6M
		from have
		where date &amp;gt;= '01Jul2023'd
		group by cust_id
;
quit;

data want;
	merge work.h1_2023 work.h2_2023;
	by cust_id;
	length Removed_Income_Sources $50;
	if Ind_Cash_Deposit_F6M and not Ind_Cash_Deposit_L6M then Removed_Income_Sources = 'Cash';
	if Ind_Check_Deposit_F6M and not Ind_Check_Deposit_L6M then Removed_Income_Sources = cat(trimn(Removed_Income_Sources),' ','Check');
	if Ind_Wage_Income_F6M and not Ind_Wage_Income_L6M then Removed_Income_Sources = cat(trimn(Removed_Income_Sources),' ','Wage');
	if Ind_SocialSeurity_Income_F6M and not Ind_SocialSeurity_Income_L6M then Removed_Income_Sources = cat(trimn(Removed_Income_Sources),' ','Social');
	if Removed_Income_Sources = ' ' then Removed_Income_Sources = 'No_change';
	else Removed_Income_Sources = left(translate(compbl(Removed_Income_Sources),'+',' '));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jan 2024 08:48:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-change-in-income-source/m-p/910804#M359153</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2024-01-08T08:48:17Z</dc:date>
    </item>
  </channel>
</rss>

