BookmarkSubscribeRSS Feed
data_null__
Jade | Level 19

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.

    2 REPLIES 2
    Tom
    Super User Tom
    Super User

    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.

    Tom
    Super User Tom
    Super User

    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 = .

    sas-innovate-wordmark-2025-midnight.png

    Register Today!

    Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


    Register now!

    How to Concatenate Values

    Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

    Find more tutorials on the SAS Users YouTube channel.

    SAS Training: Just a Click Away

     Ready to level-up your skills? Choose your own adventure.

    Browse our catalog!

    Discussion stats
    • 2 replies
    • 2425 views
    • 0 likes
    • 2 in conversation