<?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/623554#M183599</link>
    <description>&lt;P&gt;You can also mix step1 and step2 in a single step:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
	set Rawdata;
	array Ind_Expose_Mon (6);  
	do k=1 to dim(Ind_Expose_Mon);
		if k&amp;lt;=No_Mon_expose then Ind_Expose_Mon(k)=1;
		else Ind_Expose_Mon(k)=0;
	end;

	array score (6);
	do i=1 to dim(score);
		if score(i)=11 then do;
			do j = (i+1) to dim(Ind_Expose_Mon);
				Ind_Expose_Mon(j)=0;
			end;
		end;
	end;
	drop i j k;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 10 Feb 2020 13:24:48 GMT</pubDate>
    <dc:creator>ed_sas_member</dc:creator>
    <dc:date>2020-02-10T13:24:48Z</dc:date>
    <item>
      <title>Array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array/m-p/623545#M183595</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;What is the way to create data set "&lt;CODE class=" language-sas"&gt;wanted2" using array instead of multiple IF else that written manually?&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;The row data contain information for each customer ID.&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;There is information about number of months that customer was expose to illness.&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;There is also follow up of 6 months with score 1-10.&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;IF customer touch score 11 then he died and then I need to give value 0 to indicator of exposition in the following months.&lt;/CODE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&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 
11 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;
end;
else IF Score2=11 then do;
Ind_Expose_Mon3=0;
Ind_Expose_Mon4=0;
Ind_Expose_Mon5=0;
Ind_Expose_Mon6=0;
end;
else IF Score3=11 then do;
Ind_Expose_Mon4=0;
Ind_Expose_Mon5=0;
Ind_Expose_Mon6=0;
end;
else IF Score4=11 then do;
Ind_Expose_Mon5=0;
Ind_Expose_Mon6=0;
end;
else IF Score5=11 then do;
Ind_Expose_Mon6=0;
end;
Run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Feb 2020 12:51:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array/m-p/623545#M183595</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2020-02-10T12:51:58Z</dc:date>
    </item>
    <item>
      <title>Re: Array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array/m-p/623547#M183596</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am a bit confused with your request:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;For patient 3, there are 7 values for 6 scores (11 9 8 9 11 11 11). How is it possible to have score1=11 and then other values?&lt;/LI&gt;
&lt;LI&gt;Score1 refer to the 1st month of follow-up so it has nothing to do with the 1st month of exposition. What is the rational to mix values? E.g. patient 6 : month1 = exposition; month2-month7 = follow-up (died at month2) -&amp;gt; is that right?&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Thank you for the clarifications.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;</description>
      <pubDate>Mon, 10 Feb 2020 12:20:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array/m-p/623547#M183596</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-02-10T12:20:38Z</dc:date>
    </item>
    <item>
      <title>Re: Array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array/m-p/623551#M183597</link>
      <description>&lt;P&gt;For each customer there are 6 scores (in follow up period of 6 months).&lt;/P&gt;
&lt;P&gt;However,For each customer there is a different number of months that he/she exposed.&lt;/P&gt;
&lt;P&gt;So, in months after expose period the scores are not relevant (It is error information and we fix it in data set called "wanted1".&lt;/P&gt;
&lt;P&gt;It was an error in row data ,so I am sending it again (6 scores for each ID)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&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 
11 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;
end;
else IF Score2=11 then do;
Ind_Expose_Mon3=0;
Ind_Expose_Mon4=0;
Ind_Expose_Mon5=0;
Ind_Expose_Mon6=0;
end;
else IF Score3=11 then do;
Ind_Expose_Mon4=0;
Ind_Expose_Mon5=0;
Ind_Expose_Mon6=0;
end;
else IF Score4=11 then do;
Ind_Expose_Mon5=0;
Ind_Expose_Mon6=0;
end;
else IF Score5=11 then do;
Ind_Expose_Mon6=0;
end;
Run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Feb 2020 12:56:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array/m-p/623551#M183597</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2020-02-10T12:56:19Z</dc:date>
    </item>
    <item>
      <title>Re: Array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array/m-p/623553#M183598</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for the clarification.&lt;/P&gt;
&lt;P&gt;Here is a way to automatize wanted1 -&amp;gt; wanted2:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data wanted2;
	set wanted1;
	array score (6);
	array Ind_Expose_Mon (6); 
	do i=1 to dim(score);
		if score(i)=11 then do;
			do j = (i+1) to dim(Ind_Expose_Mon);
				Ind_Expose_Mon(j)=0;
			end;
		end;
	end;
	drop i j;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Feb 2020 13:22:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array/m-p/623553#M183598</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-02-10T13:22:52Z</dc:date>
    </item>
    <item>
      <title>Re: Array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array/m-p/623554#M183599</link>
      <description>&lt;P&gt;You can also mix step1 and step2 in a single step:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
	set Rawdata;
	array Ind_Expose_Mon (6);  
	do k=1 to dim(Ind_Expose_Mon);
		if k&amp;lt;=No_Mon_expose then Ind_Expose_Mon(k)=1;
		else Ind_Expose_Mon(k)=0;
	end;

	array score (6);
	do i=1 to dim(score);
		if score(i)=11 then do;
			do j = (i+1) to dim(Ind_Expose_Mon);
				Ind_Expose_Mon(j)=0;
			end;
		end;
	end;
	drop i j k;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Feb 2020 13:24:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array/m-p/623554#M183599</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-02-10T13:24:48Z</dc:date>
    </item>
  </channel>
</rss>

