BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Garyr
Calcite | Level 5

Hopefully I'm missing something obvious but at this point I'm stumped.  Any help is appreciated.


This is in SAS 9.3/1M0 on Windows7/32bit.


I can't get the var in the line statement to print to the report.  I added a string just to see if the line statement was working and the string prints just fine but not the var. 


There is no error or warning in the log - the var just doesn't show on report.

I started with the var in question to the right of the 'compute before' var but changed order of the vars in the column statement
(based on documentation and a posting on SAS-L) so var referenced in compute statement  is to the left of the 'break' var.  It doesn't work in either position.


I've also tried different formats and a bunch of other things but no joy.

Thanks for looking.
-------------------------


First the dataset.


                  Adm     Adm      Adm      Adm                    measure_   measure_value_
measure_name    Total    Res     NonRes    Pct    measure           order     order

HS GPA          3.72     3.62     3.74            Means               1       2
HS GPA             8        2        6      2%    2.5-2.99            1       1
HS GPA           117       30       87     31%    3.0-3.59            1       1
HS GPA           166       23      143     45%    3.6-4.00            1       1
HS GPA            78       10       68     21%    4.01-high           1       1
HS GPA             3        .        3      1%    Missing Data        1       1
HS Rank         78.2     74.6     79.2            Means               2       2
HS Rank            1        .        1      0%    0-29                2       1
HS Rank           13        3       10      3%    30-49               2       1
HS Rank           20        8       12      5%    50-59               2       1
HS Rank           74       19       55     20%    60-79               2       1
HS Rank           64       12       52     17%    80-80               2       1
HS Rank           72       11       61     19%    90-100              2       1
HS Rank          128       12      116     34%    Missing Data        2       1
SAT Crt Thnk     558      566      558            Means               3       2
SAT Crt Thnk       3        .        3      1%    0-399               3       1
SAT Crt Thnk      38        3       35     10%    400-499             3       1
SAT Crt Thnk      99        6       93     27%    500-599             3       1
SAT Crt Thnk      55        2       53     15%    600-699             3       1
SAT Crt Thnk       8        2        6      2%    700-800             3       1
SAT Crt Thnk     169       52      117     45%    Missing Data        3       1
SAT Math         551      524      553            Means               4       2
SAT Math           6        .        6      2%    0-399               4       1
SAT Math          43        7       36     12%    400-499             4       1
SAT Math          87        2       85     23%    500-599             4       1
SAT Math          59        3       56     16%    600-699             4       1
SAT Math           8        1        7      2%    700-800             4       1
SAT Math         169       52      117     45%    Missing Data        4       1
ACT Comp        24.9     23.5     25.3            Means               5       2
ACT Comp          17        6       11      5%    15-18               5       1
ACT Comp          60       23       37     16%    19-22               5       1
ACT Comp          92       19       73     25%    23-26               5       1
ACT Comp          90       13       77     24%    27-36               5       1
ACT Comp         113        4      109     30%    Missing Data        5       1
CCHE Index       117      113      118            Means               6       2
CCHE Index         .        .        .      .     0-89                6       1
CCHE Index        33       11       22      9%    090-100             6       1
CCHE Index       122       27       95     33%    101-114             6       1
CCHE Index       213       27      186     57%    115-160             6       1
CCHE Index         4        .        4      1%    Missing Data        6       1
---------------------------------------
Now the code.

proc report data = test nowd headskip missing out=test  ;

    columns measure_name measure_order measure_value_order
            measure ('Admitted Not Enrolled' AdmRes AdmNonRes AdmTotal AdmPct)  ;
    define measure_order / order noprint ;
    define measure_value_order / order noprint ;
    define measure_name / display noprint ;
    define measure / display order = data '00'x ;
    define AdmRes / display 'Res' right  ;
    define AdmNonRes / display 'Nonres' right ;
    define AdmTotal / display 'Total' right  ;
    define AdmPct / display 'Percent' right  ;

     compute before measure_order  ;
           line @1 '??' @5 measure_name $varying14. ;
      endcomp ;

run ;
------------------------
Finally, the output.

                         Admitted Not Enrolled
                      Res    Nonres     Total   Percent

??

   2.5-2.99             2         6         8        2%
   3.0-3.59            30        87       117       31%
   3.6-4.00            23       143       166       45%
   4.01-high           10        68        78       21%
   Missing Data         .         3         3        1%
   Means             3.62      3.74      3.72
??

   0-29                 .         1         1        0%
   30-49                3        10        13        3%
   50-59                8        12        20        5%
   60-79               19        55        74       20%
   80-80               12        52        64       17%
   90-100              11        61        72       19%
   Missing Data        12       116       128       34%
   Means             74.6      79.2      78.2
??

   0-399                .         3         3        1%
   400-499              3        35        38       10%
   500-599              6        93        99       27%
   600-699              2        53        55       15%
   700-800              2         6         8        2%
   Missing Data        52       117       169       45%
   Means              566       558       558
??

   0-399                .         6         6        2%
   400-499              7        36        43       12%
   500-599              2        85        87       23%
   600-699              3        56        59       16%
   700-800              1         7         8        2%
   Missing Data        52       117       169       45%
   Means              524       553       551
??

   15-18                6        11        17        5%
   19-22               23        37        60       16%
   23-26               19        73        92       25%
   27-36               13        77        90       24%
   Missing Data         4       109       113       30%
   Means             23.5      25.3      24.9
??

   0-89                 .         .         .         .
   090-100             11        22        33        9%
   101-114             27        95       122       33%
   115-160             27       186       213       57%
   Missing Data         .         4         4        1%
   Means              113       118       117

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
Diamond | Level 26


Hi,

  well, you have some issues. Right now, I think the DISPLAY usage for MEASURE_NAME is the problem. You could try this DEFINE Statement for MEASURE_NAME:

define measure_name / order order=data;

then try it. Or just change your compute block to COMPUTE MEASURE_NAME, instead of MEASURE_ORDER. Since they are essentially breaking the same, either one would work. But either way, I think that MEASURE_NAME has to be an ORDER item.

cynthia

View solution in original post

6 REPLIES 6
Vince28_Statcan
Quartz | Level 8

I think $varyingw. is strictly an informat

found SAS(R) 9.4 Formats and Informats: Reference but you can lookup for it in the format list it is not there. It does make some sense too. Depending on your ODS destination, you *should* be able to avoid the issue of white space padding by using a trim(measure_name).

I am not very familiar with proc report so I may be wrong about line statement supporting trim() like the put statement since there are a few features of put not supported by line

Vince

Cynthia_sas
Diamond | Level 26


Hi,

  well, you have some issues. Right now, I think the DISPLAY usage for MEASURE_NAME is the problem. You could try this DEFINE Statement for MEASURE_NAME:

define measure_name / order order=data;

then try it. Or just change your compute block to COMPUTE MEASURE_NAME, instead of MEASURE_ORDER. Since they are essentially breaking the same, either one would work. But either way, I think that MEASURE_NAME has to be an ORDER item.

cynthia

data_null__
Jade | Level 19

I posted this same reply on SAS-L.  Just a small change to what you had.

data test;
   infile cards dsd;
  
input
      measure_name:
$14.
      admtotal
      admres
      admnonres
      admpct :
percent8.
      measure :
$14.
      measure_order
      measure_value_order
   ;
   datalines;
HS GPA,3.72,3.62,3.74,,Means,1,2
HS GPA,8,2,6,2%,2.5-2.99,1,1
HS GPA,117,30,87,31%,3.0-3.59,1,1
HS GPA,166,23,143,45%,3.6-4.00,1,1
HS GPA,78,10,68,21%,4.01-high,1,1
HS GPA,3,.,3,1%,Missing Data,1,1
HS Rank,78.2,74.6,79.2,,Means,2,2
HS Rank,1,.,1,0%,0-29,2,1
HS Rank,13,3,10,3%,30-49,2,1
HS Rank,20,8,12,5%,50-59,2,1
HS Rank,74,19,55,20%,60-79,2,1
HS Rank,64,12,52,17%,80-80,2,1
HS Rank,72,11,61,19%,90-100,2,1
HS Rank,128,12,116,34%,Missing Data,2,1
SAT Crt Thnk,558,566,558,,Means,3,2
SAT Crt Thnk,3,.,3,1%,0-399,3,1
SAT Crt Thnk,38,3,35,10%,400-499,3,1
SAT Crt Thnk,99,6,93,27%,500-599,3,1
SAT Crt Thnk,55,2,53,15%,600-699,3,1
SAT Crt Thnk,8,2,6,2%,700-800,3,1
SAT Crt Thnk,169,52,117,45%,Missing Data,3,1
SAT Math,551,524,553,,Means,4,2
SAT Math,6,.,6,2%,0-399,4,1
SAT Math,43,7,36,12%,400-499,4,1
SAT Math,87,2,85,23%,500-599,4,1
SAT Math,59,3,56,16%,600-699,4,1
SAT Math,8,1,7,2%,700-800,4,1
SAT Math,169,52,117,45%,Missing Data,4,1
ACT Comp,24.9,23.5,25.3,,Means,5,2
ACT Comp,17,6,11,5%,15-18,5,1
ACT Comp,60,23,37,16%,19-22,5,1
ACT Comp,92,19,73,25%,23-26,5,1
ACT Comp,90,13,77,24%,27-36,5,1
ACT Comp,113,4,109,30%,Missing Data,5,1
CCHE Index,117,113,118,,Means,6,2
CCHE Index,.,.,.,.,0-89,6,1
CCHE Index,33,11,22,9%,090-100,6,1
CCHE Index,122,27,95,33%,101-114,6,1
CCHE Index,213,27,186,57%,115-160,6,1
CCHE Index,4,.,4,1%,Missing Data,6,1
;;;;

  
run;

options missing=' ';

proc report data = test nowd headskip missing out=test2 list /*showall*/ ;
   columns measure_order measure_name /*measure_order*/ measure_value_order
          measure (
'Admitted Not Enrolled' AdmRes AdmNonRes AdmTotal AdmPct)  ;
   define measure_order / order noprint ;
   define measure_value_order / order noprint ;
   define measure_name / order /*display*/ noprint ;
   define measure / display order = data '00'x ;
   define AdmRes / display 'Res' right  ;
   define AdmNonRes / display 'Nonres' right ;
   define AdmTotal / display 'Total' right  ;
   define AdmPct / display 'Percent' right  ;
   compute before measure_name / style=[just=left color=red];
      line measure_name $14.;
     
endcomp;
  
run;
Garyr
Calcite | Level 5

Thanks to all for your suggestions//help. 

Cynthia,  I'll try your suggestions Monday and post results here.

Tom
Super User Tom
Super User

You need to tell PROC REPORT that you want to use measure_name as an ORDER variable.

define measure_name / order order=data noprint ;

You probably do NOT want to overwrite your input data with the output data from the proc.

proc report data = test nowd headskip missing /* out=test */ ;


Apparently PROC REPORT does not generate an error message when you fail to provide the $VARYING. format with the required length variable. If you tried that in a data step you would get:

ERROR: Variable name containing length expected after $VARYING.

But you should probably either change the program to use $14. or calculate an actual length.

compute before measure_order  ;

  length=length(measure_name);

  line @1 '??' @5 measure_name $varying14. length ;

endcomp ;

Garyr
Calcite | Level 5

All that was really needed was to change the define statement for the var to be printed in the line statement to an order type instead of a display.

Tom, you are right about input and output to text dataset.  I just created the 'test' dataset for this submission (it's a subset of larger dataset) and forgot to eliminate the output 'test' dataset that I had used in trying to troubleshoot the problem.

Many thanks to all.

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
  • 6 replies
  • 2621 views
  • 0 likes
  • 5 in conversation