<?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 Replace missing values with zero for a data contains a lots of variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Replace-missing-values-with-zero-for-a-data-contains-a-lots-of/m-p/493025#M129678</link>
    <description>&lt;P&gt;I would like to replace the missing value with zero for a data contains&amp;nbsp; 132 variables by following codes,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA Step5.ar_Number_of_cit_end ;
   SET Step4.Number_of_cit_end ;
   ARRAY application(132) application20001 - application201512 ;
   DO i= 1 TO 132;
   IF application(i) eq . THEN application(i) = 0 ;
   END;
   DROP i;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;but the result shows that,&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;14   DATA Step5.ar_Number_of_cit_end ;
15      SET Step4.Number_of_cit_end ;
16      ARRAY application(132) application2001 - application201512 ;
ERROR: Too many variables defined for the dimension(s) specified for the array application.
17      DO i= 1 TO 132;
18      IF application(i) eq . THEN application(i) = 0 ;
19      END;
20      DROP i;
21   RUN;

NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).
      18:7
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set STEP5.AR_NUMBER_OF_CIT_END may be incomplete.  When this step was stopped there
         were 0 observations and 133 variables.
NOTE: DATA statement used (Total process time):
      real time           5.90 seconds
      cpu time            0.09 seconds

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I read the other subject that has a similar question and shows the following codes, but I really don't know how to put my variable into this codes,&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data "database name";  
    set "database name";
    array nm(*) _numeric_ ;
    do _n_ = 1 to dim(nm);
    nm(_n_) = coalesce(nm(_n_),0);
    END;
    DROP i;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Could you please give me some suggestions?&lt;/P&gt;&lt;P&gt;thanks in advance.&lt;/P&gt;</description>
    <pubDate>Thu, 06 Sep 2018 14:12:12 GMT</pubDate>
    <dc:creator>France</dc:creator>
    <dc:date>2018-09-06T14:12:12Z</dc:date>
    <item>
      <title>Replace missing values with zero for a data contains a lots of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-missing-values-with-zero-for-a-data-contains-a-lots-of/m-p/493025#M129678</link>
      <description>&lt;P&gt;I would like to replace the missing value with zero for a data contains&amp;nbsp; 132 variables by following codes,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA Step5.ar_Number_of_cit_end ;
   SET Step4.Number_of_cit_end ;
   ARRAY application(132) application20001 - application201512 ;
   DO i= 1 TO 132;
   IF application(i) eq . THEN application(i) = 0 ;
   END;
   DROP i;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;but the result shows that,&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;14   DATA Step5.ar_Number_of_cit_end ;
15      SET Step4.Number_of_cit_end ;
16      ARRAY application(132) application2001 - application201512 ;
ERROR: Too many variables defined for the dimension(s) specified for the array application.
17      DO i= 1 TO 132;
18      IF application(i) eq . THEN application(i) = 0 ;
19      END;
20      DROP i;
21   RUN;

NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).
      18:7
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set STEP5.AR_NUMBER_OF_CIT_END may be incomplete.  When this step was stopped there
         were 0 observations and 133 variables.
NOTE: DATA statement used (Total process time):
      real time           5.90 seconds
      cpu time            0.09 seconds

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I read the other subject that has a similar question and shows the following codes, but I really don't know how to put my variable into this codes,&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data "database name";  
    set "database name";
    array nm(*) _numeric_ ;
    do _n_ = 1 to dim(nm);
    nm(_n_) = coalesce(nm(_n_),0);
    END;
    DROP i;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Could you please give me some suggestions?&lt;/P&gt;&lt;P&gt;thanks in advance.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Sep 2018 14:12:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-missing-values-with-zero-for-a-data-contains-a-lots-of/m-p/493025#M129678</guid>
      <dc:creator>France</dc:creator>
      <dc:date>2018-09-06T14:12:12Z</dc:date>
    </item>
    <item>
      <title>Re: Replace missing values with zero for a data contains a lots of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-missing-values-with-zero-for-a-data-contains-a-lots-of/m-p/493027#M129680</link>
      <description>&lt;P&gt;If they are the only variables of a numeric type in your dataset, then you can use _numeric_:&lt;/P&gt;
&lt;PRE&gt;data want;
  set have;
  array n{*} _numeric_;  /* gets all numeric variables into array */
  do i=1 to dim(n);         /* Do for all elements */
    if n{i}=. then n{i}=0;
  end;
run;&lt;/PRE&gt;
&lt;P&gt;If its not then you need to specify them:&lt;/P&gt;
&lt;PRE&gt;data want;
  set have;
  array n{*} application20001-application201501;
  do i=1 to dim(n);         /* Do for all elements */
    if n{i}=. then n{i}=0;
  end;
run;&lt;/PRE&gt;
&lt;P&gt;However two things.&amp;nbsp; First, if this is just for a report you can use:&lt;/P&gt;
&lt;PRE&gt;options missing=0;
&lt;/PRE&gt;
&lt;P&gt;This will set an option which will display missing as zero - note affects whole session!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Secondly and more importantly, it is not a good data modelling technique to use long (transposed) datasets.&amp;nbsp; Put you data into a column, and have an actual date column alongside it:&lt;/P&gt;
&lt;P&gt;DT&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;VAL&lt;/P&gt;
&lt;P&gt;200001&amp;nbsp; &amp;nbsp;xy&lt;/P&gt;
&lt;P&gt;200101&amp;nbsp; &amp;nbsp;xy&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;This is far simpler model to work with, and makes working with the date information far easier.&amp;nbsp; At report time you can simply tranpose the data to get transposed data, best of all worlds.&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;&amp;nbsp;&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;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Sep 2018 14:20:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-missing-values-with-zero-for-a-data-contains-a-lots-of/m-p/493027#M129680</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-09-06T14:20:15Z</dc:date>
    </item>
    <item>
      <title>Re: Replace missing values with zero for a data contains a lots of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-missing-values-with-zero-for-a-data-contains-a-lots-of/m-p/493029#M129682</link>
      <description>&lt;P&gt;The list of variables does not match the dimension you specified. You told SAS to make an array with 132 variables in it and then gave it a range of names that has over 180 thousand names in it.&amp;nbsp; (201,512 - 20,001 + 1)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You don't need to tell SAS what dimension to use. It can count the names for you.&amp;nbsp; But you do need to use the real list of names.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps you can use a positional list? Use double hyphen.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ARRAY application  application20001 -- application201512 ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Perhaps you can use a prefix to find the list of names? Use a trailing colon.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ARRAY application  application20: ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Also your variable types need to match.&amp;nbsp; Period for missing and 0 are valid for numeric variables.&amp;nbsp; If the variables are character instead then use ' ' and '0' instead.&amp;nbsp; But if you are lucky the warning about converting character to number was just caused by the earlier error with defining the array,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Sep 2018 14:23:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-missing-values-with-zero-for-a-data-contains-a-lots-of/m-p/493029#M129682</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-09-06T14:23:31Z</dc:date>
    </item>
  </channel>
</rss>

