BookmarkSubscribeRSS Feed
data_null__
Jade | Level 19

Anyone have an idea why line 913 below produces an array with 6 elements, each dotted variable is doubled.  While using variable name constants in line 920 produces the expect 3 elements.  Maybe I should check the UG. :smileyblush:

909 proc report data=sashelp.class nowd list;

910 columns _numeric_;

911

912 compute before;

913 array _nb

  • age.sum height.sum weight.sum;
  • 914 rcn = seenum(dim(_nb),'DIM=');

    915 do i = 1 to dim(_nb);

    916 rcn = seenum(_nb,cats(catx('_',vname(_nb),i),'='));

    917 end;

    918 endcomp;

    919 compute after;

    920 array _na

  • 'age.sum'n 'height.sum'n 'weight.sum'n;
  • 921 rcn = seenum(dim(_na),'DIM=');

    922 do i = 1 to dim(_na);

    923 rcn = seenum(_na,cats(catx('_',vname(_na),i),'='));

    924 end;

    925 endcomp;

    926

    927 run;

    PROC REPORT DATA=SASHELP.CLASS LS=123 PS=63 SPLIT="/" CENTER ;

    COLUMN ( Age Height Weight );

    DEFINE Age / SUM FORMAT= BEST9. WIDTH=9 SPACING=2 RIGHT "Age" ;

    DEFINE Height / SUM FORMAT= BEST9. WIDTH=9 SPACING=2 RIGHT "Height" ;

    DEFINE Weight / SUM FORMAT= BEST9. WIDTH=9 SPACING=2 RIGHT "Weight" ;

    RBREAK BEFORE / ;

    RBREAK AFTER / ;

    COMPUTE BEFORE ;

    array _nb [ * ] age.sum height.sum weight.sum;

    rcn = seenum(dim(_nb), 'DIM=');

    do i = 1 to dim(_nb);

    rcn = seenum(_nb [ i ], cats(catx('_', vname(_nb [ i ]), i), '='));

    end;

    ENDCOMP;

    COMPUTE AFTER ;

    array _na [ * ] 'age.sum'n 'height.sum'n 'weight.sum'n;

    rcn = seenum(dim(_na), 'DIM=');

    do i = 1 to dim(_na);

    rcn = seenum(_na [ i ], cats(catx('_', vname(_na [ i ]), i), '='));

    end;

    ENDCOMP;

    RUN;

    DIM= 6

    Age.SUM_1= 253

    Age.SUM_2= 253

    Height.SUM_3= 1184.4

    Height.SUM_4= 1184.4

    Weight.SUM_5= 1900.5

    Weight.SUM_6= 1900.5

    DIM= 3

    Age.SUM_1= 253

    Height.SUM_2= 1184.4

    Weight.SUM_3= 1900.5

    NOTE: There were 19 observations read from the data set SASHELP.CLASS.

    NOTE: PROCEDURE REPORT used (Total process time):

    real time 0.04 seconds

    cpu time 0.04 seconds

    4 REPLIES 4
    art297
    Opal | Level 21

    DN,

    Is the difference any more than that the one call included the nowd option while the other didn't?

    data_null__
    Jade | Level 19

    There is only one PROC REPORT numbered lines 909-927 The unnumbered lines are result of LIST option and output from SEENUM.

    art297
    Opal | Level 21

    I can't find anything in the documentation that says that compound names have to be referred to with name literals.  I would think this one should be sent to tech support and will result in a hotfix.

    Ksharp
    Super User

    Null.

    Because age.sum maps two variable (age and 'age.sum'n) which age is for computed usage,'age.sum'n is for

    computed before/after usage. So you will get six variables ,while another statement is three varibales.

    So if you want get three variables before computed block, then use another three temp variables to hold these value of three variables.

    PROC REPORT DATA=SASHELP.CLASS LS=123 PS=63 SPLIT="/" CENTER   ;

    COLUMN ( Age Height Weight );

    DEFINE Age / SUM FORMAT= BEST9. WIDTH=9 SPACING=2 RIGHT "Age" ;

    DEFINE Height / SUM FORMAT= BEST9. WIDTH=9 SPACING=2 RIGHT "Height" ;

    DEFINE Weight / SUM FORMAT= BEST9. WIDTH=9 SPACING=2 RIGHT "Weight" ;

    RBREAK BEFORE / ;

    RBREAK AFTER / ;

    COMPUTE BEFORE ;

    _age=age.sum; _height=height.sum; _weight=weight.sum;

    array _nb [ * ] _age _height _weight;

    rcn = seenum(dim(_nb), 'DIM=');

    do i = 1 to dim(_nb);

    rcn = seenum(_nb [ i ], cats(catx('_', vname(_nb [ i ]), i), '='));

    end;

    ENDCOMP;

    COMPUTE AFTER ;

    array _na [ * ] 'age.sum'n 'height.sum'n 'weight.sum'n;

    rcn = seenum(dim(_na), 'DIM=');

    do i = 1 to dim(_na);

    rcn = seenum(_na [ i ], cats(catx('_', vname(_na [ i ]), i), '='));

    end;

    ENDCOMP;

    RUN;

    Ksharp

    hackathon24-white-horiz.png

    2025 SAS Hackathon: There is still time!

    Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

    Register Now

    What is Bayesian Analysis?

    Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

    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
    • 4 replies
    • 2062 views
    • 0 likes
    • 3 in conversation