<?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 and changing all impossible values in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/Array-and-changing-all-impossible-values/m-p/518269#M6700</link>
    <description>&lt;P&gt;The&amp;nbsp;column names referred in the array statement should be&amp;nbsp;&amp;nbsp;be contiguous to use the reference like&amp;nbsp;&lt;SPAN&gt;DPQ010-DPQ100. I&lt;/SPAN&gt;n your case the columns are&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;DPQ010 DP020 DP030 DP040 DP050 DP060 DP070 DP080 DP090 DP100 which are not contiguous. Moreover DPQ010-DPQ100 are seen as 90 elements by sas and the array is declared to have only 10 elements.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;You have to expand the column list , which is simplified in this example.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input SEQN DPQ010 DP020 DP030 DP040 DP050 DP060 DP070 DP080 DP090 DP100;
cards;
1 10 11 12 13 14 15 16 17 18 19 20
run;

proc contents data=have out=temp(keep=name) noprint;
run;

Proc sql noprint;
	select name into :arr_lst separated by ' '
		from temp
		where name like 'DP%';
quit;

%put &amp;amp;=arr_lst;

data Depression;
	set have;
	array codebook [10] &amp;amp;arr_lst;

	do i = 1 to 10;
		if codebook [i] = 10 then
			codebook[i] = 0;
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 03 Dec 2018 23:10:31 GMT</pubDate>
    <dc:creator>r_behata</dc:creator>
    <dc:date>2018-12-03T23:10:31Z</dc:date>
    <item>
      <title>Array and changing all impossible values</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Array-and-changing-all-impossible-values/m-p/518182#M6692</link>
      <description>&lt;P&gt;&lt;STRONG&gt;My Goal:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Create a temporary data set called Depression&amp;nbsp;that reads the dpq_h_errorsSAS data set and changes all impossible values in the depression variables to missing. The dpq_h_errors&amp;nbsp;data set is stored in the /courses/ddb976e5ba27fe300/NHANES 2013_2014&amp;nbsp;folder.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My code:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;libname in '/courses/ddb976e5ba27fe300/NHANES 2013_2014';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data Depression;&lt;BR /&gt;input SEQN DPQ010 DP020 DP030 DP040 DP050 DP060 DP070 DP080 DP090 DP100;&lt;BR /&gt;array codebook [10] DPQ010-DPQ100;&lt;BR /&gt;do i = 1 to 10;&lt;BR /&gt;if codebook [i] = 10 then codebook[i] = 0;&lt;BR /&gt;end;&lt;BR /&gt;&lt;BR /&gt;proc contents data=in.dpq_h_errors;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc print data=in.dpq_h_errors (obs=10);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;The error and warning I am getting:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;ERROR: Too many variables defined for the dimension(s) specified for the array codebook&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="sasWarning"&gt;WARNING: The data set WORK.DEPRESSION may be incomplete. When this step was stopped there were 0 observations and 12 variables.&lt;/DIV&gt;&lt;DIV class="sasWarning"&gt;WARNING: Data set WORK.DEPRESSION was not replaced because this step was stopped.&lt;/DIV&gt;</description>
      <pubDate>Mon, 03 Dec 2018 18:46:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Array-and-changing-all-impossible-values/m-p/518182#M6692</guid>
      <dc:creator>smart</dc:creator>
      <dc:date>2018-12-03T18:46:08Z</dc:date>
    </item>
    <item>
      <title>Re: Array and changing all impossible values</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Array-and-changing-all-impossible-values/m-p/518185#M6693</link>
      <description>&lt;P&gt;Try this change double dash --&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array codebook [10] DPQ010--DPQ100;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 03 Dec 2018 18:51:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Array-and-changing-all-impossible-values/m-p/518185#M6693</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-12-03T18:51:08Z</dc:date>
    </item>
    <item>
      <title>Re: Array and changing all impossible values</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Array-and-changing-all-impossible-values/m-p/518190#M6694</link>
      <description>&lt;P&gt;When I submitted the array with double dash I received these errors in&amp;nbsp;my log:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="sasSource"&gt;data Depression;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;74 input SEQN DPQ010 DP020 DP030 DP040 DP050 DP060 DP070 DP080 DP090 DP100;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;75 array codebook [10] DPQ010--DPQ100&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;76 do i = 1 to 10;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;_ __&lt;/DIV&gt;&lt;DIV class="sasError"&gt;22 22&lt;/DIV&gt;&lt;DIV class="sasError"&gt;200 200&lt;/DIV&gt;&lt;DIV class="sasError"&gt;ERROR: DPQ100 does not follow DPQ010 on the list of previously defined variables.&lt;/DIV&gt;&lt;DIV class="sasError"&gt;ERROR: Too few variables defined for the dimension(s) specified for the array codebook.&lt;/DIV&gt;&lt;DIV class="sasError"&gt;ERROR 22-322: Syntax error, expecting one of the following: a name, (, -, :, ;, _ALL_, _CHARACTER_, _CHAR_, _NUMERIC_.&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;77 if codebook [i] = 10 then codebook[i] = 0;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;78 end;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;___&lt;/DIV&gt;&lt;DIV class="sasError"&gt;161&lt;/DIV&gt;&lt;DIV class="sasError"&gt;ERROR 161-185: No matching DO/SELECT statement.&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Mon, 03 Dec 2018 19:01:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Array-and-changing-all-impossible-values/m-p/518190#M6694</guid>
      <dc:creator>smart</dc:creator>
      <dc:date>2018-12-03T19:01:00Z</dc:date>
    </item>
    <item>
      <title>Re: Array and changing all impossible values</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Array-and-changing-all-impossible-values/m-p/518197#M6696</link>
      <description>&lt;DIV class="sasSource"&gt;74 input SEQN DPQ010 &lt;STRONG&gt;DP020 DP030 DP040 DP050 DP060 DP070 DP080 DP090 DP100;/*all DP series*/&lt;/STRONG&gt;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;75 array codebook [10] DPQ010--DPQ100&amp;nbsp; /&lt;STRONG&gt;*DPQ?????????*/&lt;/STRONG&gt;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;wouldn't the array statement be&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;&lt;SPAN&gt;&amp;nbsp;array codebook [10] DPQ010-&lt;STRONG&gt;-DP100 rather?&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Mon, 03 Dec 2018 19:16:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Array-and-changing-all-impossible-values/m-p/518197#M6696</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-12-03T19:16:09Z</dc:date>
    </item>
    <item>
      <title>Re: Array and changing all impossible values</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Array-and-changing-all-impossible-values/m-p/518198#M6697</link>
      <description>&lt;P&gt;That was a typo on my part. All should be DPQ. Fixing that still gives me the following errors:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="sasError"&gt;ERROR: Too many variables defined for the dimension(s) specified for the array codebook.&lt;/DIV&gt;&lt;DIV class="sasError"&gt;ERROR 22-322: Syntax error, expecting one of the following: a name, (, -, :, ;, _ALL_, _CHARACTER_, _CHAR_, _NUMERIC_.&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;77 if codebook [i] = 10 then codebook[i] = 0;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;78 end;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;___&lt;/DIV&gt;&lt;DIV class="sasError"&gt;161&lt;/DIV&gt;&lt;DIV class="sasError"&gt;ERROR 161-185: No matching DO/SELECT statement.&lt;/DIV&gt;</description>
      <pubDate>Mon, 03 Dec 2018 19:20:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Array-and-changing-all-impossible-values/m-p/518198#M6697</guid>
      <dc:creator>smart</dc:creator>
      <dc:date>2018-12-03T19:20:14Z</dc:date>
    </item>
    <item>
      <title>Re: Array and changing all impossible values</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Array-and-changing-all-impossible-values/m-p/518203#M6698</link>
      <description>&lt;P&gt;can you post your code plz&lt;/P&gt;</description>
      <pubDate>Mon, 03 Dec 2018 19:25:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Array-and-changing-all-impossible-values/m-p/518203#M6698</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-12-03T19:25:21Z</dc:date>
    </item>
    <item>
      <title>Re: Array and changing all impossible values</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Array-and-changing-all-impossible-values/m-p/518269#M6700</link>
      <description>&lt;P&gt;The&amp;nbsp;column names referred in the array statement should be&amp;nbsp;&amp;nbsp;be contiguous to use the reference like&amp;nbsp;&lt;SPAN&gt;DPQ010-DPQ100. I&lt;/SPAN&gt;n your case the columns are&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;DPQ010 DP020 DP030 DP040 DP050 DP060 DP070 DP080 DP090 DP100 which are not contiguous. Moreover DPQ010-DPQ100 are seen as 90 elements by sas and the array is declared to have only 10 elements.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;You have to expand the column list , which is simplified in this example.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input SEQN DPQ010 DP020 DP030 DP040 DP050 DP060 DP070 DP080 DP090 DP100;
cards;
1 10 11 12 13 14 15 16 17 18 19 20
run;

proc contents data=have out=temp(keep=name) noprint;
run;

Proc sql noprint;
	select name into :arr_lst separated by ' '
		from temp
		where name like 'DP%';
quit;

%put &amp;amp;=arr_lst;

data Depression;
	set have;
	array codebook [10] &amp;amp;arr_lst;

	do i = 1 to 10;
		if codebook [i] = 10 then
			codebook[i] = 0;
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 03 Dec 2018 23:10:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Array-and-changing-all-impossible-values/m-p/518269#M6700</guid>
      <dc:creator>r_behata</dc:creator>
      <dc:date>2018-12-03T23:10:31Z</dc:date>
    </item>
    <item>
      <title>Re: Array and changing all impossible values</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Array-and-changing-all-impossible-values/m-p/518588#M6701</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You are doing a very roundabout way to get a list of variable names, based on the first 2 letters of those name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This single step does&amp;nbsp;what I think you want.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data depression;
  set have;
  array codebook {*} dp: ;
  do i=1 to dim(codebook);
    if codebook{i}=10 then codebook{i}=0;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&amp;nbsp;this uses the expression DP:&amp;nbsp;&amp;nbsp; to indicate all vars whose names begin with DP.&lt;/LI&gt;
&lt;LI&gt;It uses an asterisk in the braces, telling sas to figure out how many elements are in the array&lt;/LI&gt;
&lt;LI&gt;And it uses &lt;EM&gt;&lt;STRONG&gt;dim(codebook)&lt;/STRONG&gt;&lt;/EM&gt; instead of &lt;EM&gt;&lt;STRONG&gt;10&lt;/STRONG&gt;&lt;/EM&gt; as the do loop upper limit.&amp;nbsp; There's no need for you to know the size in advance.&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Tue, 04 Dec 2018 21:41:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Array-and-changing-all-impossible-values/m-p/518588#M6701</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-12-04T21:41:03Z</dc:date>
    </item>
    <item>
      <title>Re: Array and changing all impossible values</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Array-and-changing-all-impossible-values/m-p/518591#M6702</link>
      <description>&lt;P&gt;Thanks for pointing out&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;&amp;nbsp;. Wondering how i missed that one.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Dec 2018 21:48:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Array-and-changing-all-impossible-values/m-p/518591#M6702</guid>
      <dc:creator>r_behata</dc:creator>
      <dc:date>2018-12-04T21:48:33Z</dc:date>
    </item>
    <item>
      <title>Re: Array and changing all impossible values</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Array-and-changing-all-impossible-values/m-p/518977#M6707</link>
      <description>&lt;P&gt;This works thank you so much!&lt;/P&gt;</description>
      <pubDate>Wed, 05 Dec 2018 23:05:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Array-and-changing-all-impossible-values/m-p/518977#M6707</guid>
      <dc:creator>smart</dc:creator>
      <dc:date>2018-12-05T23:05:36Z</dc:date>
    </item>
  </channel>
</rss>

