DATA Step, Macro, Functions and more

WARNING: Partial value initialization of the array (Revisited)

Reply
Respected Advisor
Posts: 3,799

WARNING: Partial value initialization of the array (Revisited)

I'm reposting my previous hijacked thread on this subject. Smiley Happy  I am NOT interested in doing ANYTHING that SAS already knows how to do.

I may have asked this before I've been thinking about it for a long time.

Suppose I want to collect user input in the form of an array initialization.  I want to use SAS to parse or expand the initialization e.g.

152 %let parm = (4*40 3*(3*7 8 9 10));

153 data _null_;

154 array parm[30];

155 retain parm &parm;

WARNING: Partial value initialization of the array parm.

156 put (parm

  • ) (/=);
  • 157 run;

    parm1=40

    parm2=40

    parm3=40

    parm4=40

    parm5=7

    parm6=7

    parm7=7

    parm8=8

    parm9=9

    parm10=10

    parm11=7

    parm12=7

    parm13=7

    parm14=8

    parm15=9

    parm16=10

    parm17=7

    parm18=7

    parm19=7

    parm20=8

    parm21=9

    parm22=10

    parm23=.

    parm24=.

    parm25=.

    parm26=.

    parm27=.

    parm28=.

    parm29=.

    parm30=.


    As you can see SAS knows just what to do and give me exactly what I want.  I just don't want the warning.  I even works for character strings.

    204 %let parm = (4*'hello kitty' 3*(3*('hello yourself')));

    205 data _null_;

    206 array parm[30] $32;

    207 retain parm &parm;

    WARNING: Partial value initialization of the array parm.

    208 put (parm

  • ) (/=);
  • 209 run;

    parm1=hello kitty

    parm2=hello kitty

    parm3=hello kitty

    parm4=hello kitty

    parm5=hello yourself

    parm6=hello yourself

    parm7=hello yourself

    parm8=hello yourself

    parm9=hello yourself

    parm10=hello yourself

    parm11=hello yourself

    parm12=hello yourself

    parm13=hello yourself

    parm14=

    parm15=

    parm16=

    parm17=

    parm18=

    parm19=

    parm20=

    parm21=

    parm22=

    parm23=

    parm24=

    parm25=

    parm26=

    parm27=

    parm28=

    parm29=

    parm30=

    The only way I can see to get rid of the warning it to know what the number of elements the "initialization list" is going to produce.  But I ain't smart enough for that and why should I need to cause SAS knows already.  I just don't want to be warned.

    Perhaps another feature in SAS accepts the same "initialization list" syntax that doesn't produce the WARNING.

    Super User
    Super User
    Posts: 7,039

    WARNING: Partial value initialization of the array (Revisited)

    Posted in reply to data_null__

    Did you look at the PARMS statement for GLIMMIX, VARIOGRAM etc?  The syntax is a little different but if there is anyway to get it to generate the values and output them into a dataset then you could pull those values into a space delimited values to use for the ARRAY statement.

    Super User
    Super User
    Posts: 7,039

    WARNING: Partial value initialization of the array (Revisited)

    Posted in reply to data_null__

    Proc POWER also has number lists.  Perhaps this can be used to expand a list of values?

    Number-Lists

    A number-list can be one of two things: a series of one or more numbers expressed in the form of one or more DOLISTs, or a missing value indicator (.).

    The DOLIST format is the same as in the DATA step language. For example, for the one-sample  test you can specify four scenarios (30, 50, 70, and 100) for a total sample size in any of the following ways.

       NTOTAL = 30 50 70 100   NTOTAL = 30 to 70 by 20 100

    A missing value identifies a parameter as the result parameter; it is valid only with options representing parameters you can solve for in a given analysis. For example, you can request a solution for NTOTAL:

       NTOTAL = .
    Ask a Question
    Discussion stats
    • 2 replies
    • 482 views
    • 0 likes
    • 2 in conversation