<?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: Flagging potential errors using arrays- Data Managment Question in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Flagging-potential-errors-using-arrays-Data-Managment-Question/m-p/630885#M186823</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/315825"&gt;@AO88&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Welcome to the community!&lt;/P&gt;
&lt;P&gt;Could this code answer your question?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data datainput_array;
	set datainput;
	array Q4a_ARRAY (*) Q4a:;
	
	/*Q4a_flag = 0 if all values are set to 0*/
	/*Q4a_flag = 1 if at least one value is set to 1*/
	if sum(of Q4a_ARRAY(*)) = 0 then Q4a_flag = 0;
	else if sum(of Q4a_ARRAY(*)) &amp;gt; 0 then Q4a_flag = 1;
run;

proc freq data=datainput_array;
	TABLE Question4*Q4a_flag / nocum nopercent norow nocol out=Q4_stat (drop=percent) sparse;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Best,&lt;/P&gt;</description>
    <pubDate>Tue, 10 Mar 2020 12:45:01 GMT</pubDate>
    <dc:creator>ed_sas_member</dc:creator>
    <dc:date>2020-03-10T12:45:01Z</dc:date>
    <item>
      <title>Flagging potential errors using arrays- Data Managment Question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-potential-errors-using-arrays-Data-Managment-Question/m-p/630880#M186821</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This lies more along the realm of data management.&lt;/P&gt;&lt;P&gt;I have a dataset where I want to flag observations for errors. The variables are a set of questions/responses&amp;nbsp;and the responses are either Yes (1) or No (0). As you'll see in the example dataset below, variables Q4a1 to Q4a9 are a group of responses from&amp;nbsp;&amp;nbsp;'Question4.' If a respondent answers 'Yes' to question 4, then at least one entry (Yes) must be made in variables Q4a1 to Q4a9.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Question4-Do you have a favorite food? (Yes-1/No-0)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Check box&lt;/P&gt;&lt;P&gt;Q4a1- Pizza (Response is either&amp;nbsp;1 or 0)&lt;/P&gt;&lt;P&gt;Q4a2-Steak (1/0)&lt;/P&gt;&lt;P&gt;Q4a4- Pasta (1/0)&lt;/P&gt;&lt;P&gt;Q4a5- Other (1/0)&lt;/P&gt;&lt;P&gt;.....etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to be able to flag&amp;nbsp;respondents where they answered yes to Question 4 but they made no selection for Q4a1 through Q4a9.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I created an array but i'm running into difficulty where it seems to be flagging respondents (variable Data1-Data12)&amp;nbsp;that didn't make a selection for&amp;nbsp;the last response (Q4a9) instead of flagging 'Data2' and 'Data4' where&amp;nbsp;no entries were made in Q4a1 - Q4a9.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The frequency table should be:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;Q4a&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;Freq&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;0&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;9&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;1&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Where 2 respondents that made no selections&amp;nbsp;in Q4a1-Q4a9&amp;nbsp;are flagged.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But instead I'm getting this:&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;Q4a&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;Freq&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;0&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;4&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;1&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;7&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Where it seems to be flagging non-responses for Q4a9.&lt;/P&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;&lt;P&gt;Have attached code below:&lt;/P&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;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; DataInput;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;input&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Data $ Question1:&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;32.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; Question2:&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;32.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; Question3:&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;32.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; Question4:&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;32.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; Q4a1:&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;32.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; Q4a2:&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;32.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; Q4a3:&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;32.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; Q4a4:&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;32.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; Q4a5:&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;32.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; Q4a6:&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;32.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; Q4a7:&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;32.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; Q4a8:&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;32.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; Q4a9:&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;32.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;datalines&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA1 0 1 1 0 1 0 0 0 0 0 0 0 1 1&lt;/P&gt;&lt;P&gt;DATA2 1 0 0 1 0 0 0 0 0 0 0 0 0 0&lt;/P&gt;&lt;P&gt;DATA3 1 1 0 1 1 1 1 0 1 0 1 1 0 0&lt;/P&gt;&lt;P&gt;DATA4 1 0 0 1 0 0 0 0 0 0 0 0 0 0&lt;/P&gt;&lt;P&gt;DATA5 1 1 0 1 0 1 0 1 1 1 1 0 1 1&lt;/P&gt;&lt;P&gt;DATA6 1 1 0 1 0 1 0 1 1 1 1 0 1 1&lt;/P&gt;&lt;P&gt;DATA7 1 1 0 1 0 1 0 1 1 1 1 0 1 1&lt;/P&gt;&lt;P&gt;DATA8 1 1 0 1 0 1 0 1 1 1 1 0 1 1&lt;/P&gt;&lt;P&gt;DATA9 1 1 0 1 0 0 0 0 0 0 0 1 0 0&lt;/P&gt;&lt;P&gt;DATA10 1 1 0 1 0 0 0 0 0 0 0 1 0 0&lt;/P&gt;&lt;P&gt;DATA11 1 1 0 1 0 1 0 1 1 1 1 1 0 0&lt;/P&gt;&lt;P&gt;DATA12 1 1 0 1 0 1 0 1 1 1 1 1 0 0&lt;/P&gt;&lt;P&gt;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; datainput_array;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; datainput;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;array&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Q4a_ARRAY (&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;9&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;) Q4a1 - Q4a9;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; i= &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;to&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;9&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Question1=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;then&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Question4=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; and&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;(Q4a_ARRAY(i) = &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Q4a=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;else&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Q4a=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;freq&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;data&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=datainput_array;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;TABLE&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Q4a;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;RUN&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;sort&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;data&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=datainput_array &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;out&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=Q4a_0;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;Where&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Q4a=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;by&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Data;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;sort&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;data&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=datainput_array &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;out&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=Q4a_1;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;Where&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Q4a=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;by&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Data;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Mar 2020 12:18:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-potential-errors-using-arrays-Data-Managment-Question/m-p/630880#M186821</guid>
      <dc:creator>AO88</dc:creator>
      <dc:date>2020-03-10T12:18:14Z</dc:date>
    </item>
    <item>
      <title>Re: Flagging potential errors using arrays- Data Managment Question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-potential-errors-using-arrays-Data-Managment-Question/m-p/630885#M186823</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/315825"&gt;@AO88&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Welcome to the community!&lt;/P&gt;
&lt;P&gt;Could this code answer your question?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data datainput_array;
	set datainput;
	array Q4a_ARRAY (*) Q4a:;
	
	/*Q4a_flag = 0 if all values are set to 0*/
	/*Q4a_flag = 1 if at least one value is set to 1*/
	if sum(of Q4a_ARRAY(*)) = 0 then Q4a_flag = 0;
	else if sum(of Q4a_ARRAY(*)) &amp;gt; 0 then Q4a_flag = 1;
run;

proc freq data=datainput_array;
	TABLE Question4*Q4a_flag / nocum nopercent norow nocol out=Q4_stat (drop=percent) sparse;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Best,&lt;/P&gt;</description>
      <pubDate>Tue, 10 Mar 2020 12:45:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-potential-errors-using-arrays-Data-Managment-Question/m-p/630885#M186823</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-03-10T12:45:01Z</dc:date>
    </item>
    <item>
      <title>Re: Flagging potential errors using arrays- Data Managment Question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-potential-errors-using-arrays-Data-Managment-Question/m-p/630889#M186824</link>
      <description>Thank you &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292097"&gt;@ed_sas_member&lt;/a&gt; ! Yes this worked. Got an error when I did proc freq, but then I changed it from Q4a_all to Q4a_flag.&lt;BR /&gt;&lt;BR /&gt;Can I still be able to include a "then do" statement to this?</description>
      <pubDate>Tue, 10 Mar 2020 12:51:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-potential-errors-using-arrays-Data-Managment-Question/m-p/630889#M186824</guid>
      <dc:creator>AO88</dc:creator>
      <dc:date>2020-03-10T12:51:35Z</dc:date>
    </item>
    <item>
      <title>Re: Flagging potential errors using arrays- Data Managment Question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-potential-errors-using-arrays-Data-Managment-Question/m-p/630890#M186825</link>
      <description>&lt;P&gt;The issue with your code comes from the statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if Question4=1 and&lt;BR /&gt;(Q4a_ARRAY(i) = 0) then Q4a=1; else Q4a=0;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Indeed, the value of the next question will override the value of the previous one.&lt;/P&gt;
&lt;P&gt;Ex. with data1:&lt;/P&gt;
&lt;TABLE class="table" aria-label="Table WORK.DATAINPUT"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="header" scope="col"&gt;&amp;nbsp;&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;Question1&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;Question2&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;Question3&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;Question4&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;Q4a1&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;Q4a2&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;Q4a3&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;Q4a4&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;Q4a5&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;Q4a6&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;Q4a7&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;Q4a8&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;Q4a9&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;&amp;nbsp;&lt;/TH&gt;
&lt;TD class="data"&gt;DATA1&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;BR /&gt;i=1 -&amp;gt; Question4=1 and(Q4a_ARRAY(1) = 0 =&amp;gt; Q4a is set to 0;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;i=2 -&amp;gt; Question4=1 and(Q4a_ARRAY(2) = 1 =&amp;gt; Q4a is now set to 1;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;i=3 -&amp;gt; Question4=1 and(Q4a_ARRAY(3) = 0 =&amp;gt; Q4a is now set to 0;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;...&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;-&amp;gt; the final value of&amp;nbsp;Q4a corresponds to the last check for&amp;nbsp;&amp;nbsp;Q4a_ARRAY(9)&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Mar 2020 12:52:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-potential-errors-using-arrays-Data-Managment-Question/m-p/630890#M186825</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-03-10T12:52:40Z</dc:date>
    </item>
    <item>
      <title>Re: Flagging potential errors using arrays- Data Managment Question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-potential-errors-using-arrays-Data-Managment-Question/m-p/630891#M186826</link>
      <description>&lt;P&gt;Awesome!&lt;/P&gt;
&lt;P&gt;For sure, you can.&lt;/P&gt;
&lt;P&gt;Please does not hesitate to share you code if you experience trouble to achieve this.&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;</description>
      <pubDate>Tue, 10 Mar 2020 12:53:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-potential-errors-using-arrays-Data-Managment-Question/m-p/630891#M186826</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-03-10T12:53:41Z</dc:date>
    </item>
    <item>
      <title>Re: Flagging potential errors using arrays- Data Managment Question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-potential-errors-using-arrays-Data-Managment-Question/m-p/630892#M186827</link>
      <description>Okay I see now, so that's why when doing a freq it only showed responses for Q4a9. Once again thank you!!! This really helped!</description>
      <pubDate>Tue, 10 Mar 2020 12:56:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-potential-errors-using-arrays-Data-Managment-Question/m-p/630892#M186827</guid>
      <dc:creator>AO88</dc:creator>
      <dc:date>2020-03-10T12:56:59Z</dc:date>
    </item>
    <item>
      <title>Re: Flagging potential errors using arrays- Data Managment Question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-potential-errors-using-arrays-Data-Managment-Question/m-p/631202#M186991</link>
      <description>&lt;!--   x-tinymce/html   --&gt;&lt;P&gt;&lt;SPAN&gt;Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292097"&gt;@ed_sas_member&lt;/a&gt; (and anyone else as well)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I've got another question.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;What if the outcome wasn't a binomial response and instead was free text. So it's the same set-up except the respondent has to type something in. How can I check to see that at least one response was typed out in the Q4a1-Q4a9? (Doesn't matter the content but just being able to note that something was or wasn't entered).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How would I handle the array if the variables are character and not numeric?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Before I would've done it like this&amp;nbsp;(using the same array):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To flag respondents where all responses&amp;nbsp;to Q4a1-Q4a9&amp;nbsp; are missing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Question4=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; and&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;(Q4a_ARRAY(i)= &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;''&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Q4a=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;else&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Q4a=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Mar 2020 11:39:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-potential-errors-using-arrays-Data-Managment-Question/m-p/631202#M186991</guid>
      <dc:creator>AO88</dc:creator>
      <dc:date>2020-03-11T11:39:24Z</dc:date>
    </item>
    <item>
      <title>Re: Flagging potential errors using arrays- Data Managment Question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-potential-errors-using-arrays-Data-Managment-Question/m-p/631213#M186994</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/315825"&gt;@AO88&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this case, you could do this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data datainput_array;
	set datainput;
	array Q4a_ARRAY (*) $ Q4a:;
	/* Q4a_flag = 0 if at least one Q4ax is not null (including trailing blanks if any)*/
	/* Q4a_flag = 1 if at all Q4ax are null (including trailing blanks if any)*/
	do i=1 to dim(Q4a_ARRAY);
		if strip(Q4a_ARRAY(i)) ne "" then do;
				Q4a_flag = 0;
				leave;
			end;
		else Q4a_flag = 1;
	end;
run;
proc print;

proc freq data=datainput_array;
	TABLE Question4*Q4a_flag / nocum nopercent norow nocol out=Q4_stat (drop=percent) sparse;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Mar 2020 12:12:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-potential-errors-using-arrays-Data-Managment-Question/m-p/631213#M186994</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-03-11T12:12:54Z</dc:date>
    </item>
    <item>
      <title>Re: Flagging potential errors using arrays- Data Managment Question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-potential-errors-using-arrays-Data-Managment-Question/m-p/631214#M186995</link>
      <description>Another question as well. What would also happen if Variable Q4a9 was a character variable. In that case would array be set up like:&lt;BR /&gt;&lt;BR /&gt;array Q4a_ARRAY (8) Q4a1-Q4a8;&lt;BR /&gt;do i= 1 to 8;&lt;BR /&gt;/*Q4a_flag = 0 if all values are set to 0*/&lt;BR /&gt;/*Q4a_flag = 1 if at least one value is set to 1*/&lt;BR /&gt;if sum(of Q4a_ARRAY(i)) = 0 then Q4a_flag = 1;&lt;BR /&gt;else if sum(of Q4a_ARRAY(*)) &amp;gt; 0 then Q4a_flag = 0;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 11 Mar 2020 12:19:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-potential-errors-using-arrays-Data-Managment-Question/m-p/631214#M186995</guid>
      <dc:creator>AO88</dc:creator>
      <dc:date>2020-03-11T12:19:20Z</dc:date>
    </item>
    <item>
      <title>Re: Flagging potential errors using arrays- Data Managment Question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-potential-errors-using-arrays-Data-Managment-Question/m-p/631216#M186996</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/315825"&gt;@AO88&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I see two approaches:&lt;/P&gt;
&lt;P&gt;- the one you suggest : put&amp;nbsp;&lt;SPAN&gt;Q4a1-Q4a8&lt;/SPAN&gt;&amp;nbsp;in the array to create a temporary flag. Then, compare this flag to Q4a9 -&amp;gt; e.g. if flag=0 and&amp;nbsp;Q4a9=" " then&amp;nbsp;&lt;SPAN&gt;Q4a_flag=0&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;-&amp;nbsp;another approach could be to create a numeric dummy variable which is equal to 1 when&amp;nbsp;Q4a9 is not null and à otherwise. -&amp;gt; and then put&amp;nbsp;Q4a1-Q4a8 and this dummy variable in the array.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Hope this helps!&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;My best,&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Mar 2020 12:24:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-potential-errors-using-arrays-Data-Managment-Question/m-p/631216#M186996</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-03-11T12:24:57Z</dc:date>
    </item>
  </channel>
</rss>

