<?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: Array in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Array/m-p/623607#M183626</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;Please delete my previous message and I will try to explain again my question.&lt;/P&gt;
&lt;P&gt;The raw data contain information for each customer ID.&lt;BR /&gt;There is information about number of months that customer was expose to illness.&lt;BR /&gt;There is also follow up of 6 months with score&amp;nbsp; value 1-11.&lt;BR /&gt;&lt;STRONG&gt;IF customer touch score 11 then he died.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;For each customer there are 6 scores (in follow up period of 6 months).&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So if the customer died at month 2 they continued to check if the customer was still dead at month 3, 4, 5 and 6????&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might actually show what "wanted2" should look like.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It might be appropriate to describe a bit of what is done with the data later. The content of your description makes this sound like you may be going for some sort of survival analysis. And any of those will likely be better off with one record per observation including the month and the score and then not have any records following "death".&lt;/P&gt;</description>
    <pubDate>Mon, 10 Feb 2020 16:25:43 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2020-02-10T16:25:43Z</dc:date>
    <item>
      <title>Array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array/m-p/623555#M183600</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;Please delete my previous message and I will try to explain again my question.&lt;/P&gt;
&lt;P&gt;The raw data contain information for each customer ID.&lt;BR /&gt;There is information about number of months that customer was expose to illness.&lt;BR /&gt;There is also follow up of 6 months with score&amp;nbsp; value 1-11.&lt;BR /&gt;IF customer touch score 11 then he died.&lt;/P&gt;
&lt;P&gt;For each customer there are 6 scores (in follow up period of 6 months).&lt;/P&gt;
&lt;P&gt;For each customer there is a different number of months that he/she exposed.&lt;/P&gt;
&lt;P&gt;For example: IF&amp;nbsp;No_Mon_expose=4&amp;nbsp; then&amp;nbsp;Score5 and&amp;nbsp;Score6 will get null values&amp;nbsp; and&amp;nbsp;Ind_Expose_Mon5=0 and&amp;nbsp;Ind_Expose_Mon6=0.&lt;/P&gt;
&lt;P&gt;In months after expose period the scores are not relevant (we fix it in data set called "wanted1")&lt;/P&gt;
&lt;P&gt;&amp;nbsp;What is the way to create data set "wanted2" using array instead of multiple IF else that written manually?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data Rawdata;
Input ID No_Mon_expose Score1 Score2 Score3 Score4 Score5 Score6;
cards;
1 6 5 5 5 5 5 4
2 3 11 11 11 11 11 11
3 3 9 8 9 11 11 11
4 4 3 3 3 3 3 3 
5 2 5 5 5 5 5 5 
6 1 11 11 11 11 11 11 
7 6 2 2 2 2 2 2 
8 3 2 2 2 2 2 2 
9 2 3 3 4 2 2 2 
10 6 2 2 2 2 2 2 
;
run;

data wanted1;
	set Rawdata;
	array Ind_Expose_Mon (6);  
	do i=1 to dim(Ind_Expose_Mon);
		if i&amp;lt;=No_Mon_expose then Ind_Expose_Mon(i)=1;
		else Ind_Expose_Mon(i)=0;
	end;
	drop i;
run;
Data wanted2;
Set wanted1;
IF Score1=11 then do;
Ind_Expose_Mon2=0;
Ind_Expose_Mon3=0;
Ind_Expose_Mon4=0;
Ind_Expose_Mon5=0;
Ind_Expose_Mon6=0;
Score2=.;
Score3=.;
Score4=.;
Score5=.;
Score6=.;
end;
else IF Score2=11 then do;
Ind_Expose_Mon3=0;
Ind_Expose_Mon4=0;
Ind_Expose_Mon5=0;
Ind_Expose_Mon6=0;
Score3=.;
Score4=.;
Score5=.;
Score6=.;
end;
else IF Score3=11 then do;
Ind_Expose_Mon4=0;
Ind_Expose_Mon5=0;
Ind_Expose_Mon6=0;
Score4=.;
Score5=.;
Score6=.;
end;
else IF Score4=11 then do;
Ind_Expose_Mon5=0;
Ind_Expose_Mon6=0;
Score5=.;
Score6=.;
end;
else IF Score5=11 then do;
Ind_Expose_Mon6=0;
Score6=.;
end;
Run;


PROC SQL;
	create table summaryInfo  as
	select 
sum(case when  Score1=11 then 1 else 0 end ) as No_Failures_Mon1,
           sum( Ind_Expose_Mon1) as No_Customers_Expose_Mon1,
		   calculated No_Failures_Mon1/calculated No_Customers_Expose_Mon1 as q1,
sum(case when  Score2=11 then 1 else 0 end ) as No_Failures_Mon2,
           sum( Ind_Expose_Mon2) as No_Customers_Expose_Mon2,
		   calculated No_Failures_Mon2/calculated No_Customers_Expose_Mon2 as q2,
sum(case when  Score3=11 then 1 else 0 end ) as No_Failures_Mon3,
           sum( Ind_Expose_Mon3) as No_Customers_Expose_Mon3,
		   calculated No_Failures_Mon3/calculated No_Customers_Expose_Mon3 as q3,
sum(case when  Score4=11 then 1 else 0 end ) as No_Failures_Mon4,
           sum( Ind_Expose_Mon4) as No_Customers_Expose_Mon4,
		   calculated No_Failures_Mon4/calculated No_Customers_Expose_Mon4 as q4,
sum(case when  Score5=11 then 1 else 0 end ) as No_Failures_Mon5,
           sum( Ind_Expose_Mon5) as No_Customers_Expose_Mon5,
		   calculated No_Failures_Mon5/calculated No_Customers_Expose_Mon5 as q5,
sum(case when  Score6=11 then 1 else 0 end ) as No_Failures_Mon6,
           sum( Ind_Expose_Mon6) as No_Customers_Expose_Mon6,
		   calculated No_Failures_Mon6/calculated No_Customers_Expose_Mon6 as q6,
(1-calculated q1)*(1-calculated q2)*(1-calculated q3)*(1-calculated q4)*(1-calculated q5)*(1-calculated q6) as prob_survive
	from  wanted2
;
QUIT;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Feb 2020 13:26:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array/m-p/623555#M183600</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2020-02-10T13:26:17Z</dc:date>
    </item>
    <item>
      <title>Re: Array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array/m-p/623557#M183601</link>
      <description>&lt;P&gt;Instead of showing the code (that you don't want to use) for WANT show the data. &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Feb 2020 13:32:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array/m-p/623557#M183601</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2020-02-10T13:32:57Z</dc:date>
    </item>
    <item>
      <title>Re: Array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array/m-p/623593#M183617</link>
      <description>&lt;P&gt;Sorry ,I didn't understand what you mean&lt;/P&gt;</description>
      <pubDate>Mon, 10 Feb 2020 15:55:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array/m-p/623593#M183617</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2020-02-10T15:55:09Z</dc:date>
    </item>
    <item>
      <title>Re: Array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array/m-p/623595#M183619</link>
      <description>&lt;P&gt;Post the dataset that you want to get from the input you posted. Post it in the form of a data step like you did with the input data.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Feb 2020 15:56:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array/m-p/623595#M183619</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-02-10T15:56:47Z</dc:date>
    </item>
    <item>
      <title>Re: Array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array/m-p/623607#M183626</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;Please delete my previous message and I will try to explain again my question.&lt;/P&gt;
&lt;P&gt;The raw data contain information for each customer ID.&lt;BR /&gt;There is information about number of months that customer was expose to illness.&lt;BR /&gt;There is also follow up of 6 months with score&amp;nbsp; value 1-11.&lt;BR /&gt;&lt;STRONG&gt;IF customer touch score 11 then he died.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;For each customer there are 6 scores (in follow up period of 6 months).&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So if the customer died at month 2 they continued to check if the customer was still dead at month 3, 4, 5 and 6????&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might actually show what "wanted2" should look like.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It might be appropriate to describe a bit of what is done with the data later. The content of your description makes this sound like you may be going for some sort of survival analysis. And any of those will likely be better off with one record per observation including the month and the score and then not have any records following "death".&lt;/P&gt;</description>
      <pubDate>Mon, 10 Feb 2020 16:25:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array/m-p/623607#M183626</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-02-10T16:25:43Z</dc:date>
    </item>
  </channel>
</rss>

