DATA Step, Macro, Functions and more

proc report getting values as 1 while doing across

Accepted Solution Solved
Reply
Regular Contributor
Posts: 161
Accepted Solution

proc report getting values as 1 while doing across

I am using proc report and using across and analysis and while getting the final output i get values as 1 for all which should not be the case. any help where i am going wrong?

 

sample data attached

 

proc report data = inc out=ngf nowd split = "¤" headline missing contents = "";
          column rpt_varn rpt_var  actarm rpt_cat count dummy ;
          define actarm / group style(header)={just=left cellwidth=1.5cm} style(column)=IdColIndent2{asis=on} "Description of Actual Arm";
          define rpt_cat / across order=internal style(header)={just=center } style(column)=IdColIndent2{asis=on};
          define rpt_varn / group order=internal noprint;
          define rpt_var / group style={just=left cellwidth=3.5cm} " ";
          define count /analysis  sum style={just=right cellwidth=1.57142857142856cm} " ";
          define dummy /noprint;
          compute before;
          line @1 ' ';
          endcomp;
          compute after rpt_varn;
          line ' ';
          endcomp;
run;

 

Attachment

Accepted Solutions
Solution
3 weeks ago
Super User
Posts: 11,343

Re: proc report getting values as 1 while doing across

You might want to try

column rpt_varn rpt_var  actarm rpt_cat, count dummy ;

The , after rpt_cat says that you want to summarize count for each level of rpt_cat.

 

Since you didn't actually have any values associated with rep_cat it was, I believe, defaulting to an N statistic as the variable rpt_cat is character and that is the default statistic for character (hard to sum character variables...)

View solution in original post


All Replies
Super User
Super User
Posts: 7,997

Re: proc report getting values as 1 while doing across

It sounds like it is being rounded, do you have values of 0.xx?  Apply a format to the one in question.  Or do your calculations in a datastep and keep the proc report simple - this is what I do, don't like doing data manipulation in an output procedure.

Regular Contributor
Posts: 161

Re: proc report getting values as 1 while doing across

It is not rounded as i attached the final dataset and it has values which are different

Super User
Super User
Posts: 7,997

Re: proc report getting values as 1 while doing across

I didn't say the data was rounded, as you are doing calculations in the proc report the data within the proc report may get rounded.  One very good reason not to do calculations and data processing in an output procedure.  Put out= onto your proc report step and see the data being used there, if that looks ok, then check your output destination - Excel for instance is a constent offender on "features" which destroy your data - for instance, rounding and truncation.

Super User
Posts: 11,343

Re: proc report getting values as 1 while doing across

I have to say that specifying a cell width of

1.57142857142856cm

 

Appears to be a tad bit of overkill. You are trying to control width of something to about the width of a single ink molecule and significantly less than the width of single pixels on a monitor even a very high resolution one.

 

Can you see any actual difference in the output if you use 1.57cm?

 

Regular Contributor
Posts: 161

Re: proc report getting values as 1 while doing across

I still get the same result if i make it to 1.57cm. somehow i get all 1's and wondering from where it is evolving

Solution
3 weeks ago
Super User
Posts: 11,343

Re: proc report getting values as 1 while doing across

You might want to try

column rpt_varn rpt_var  actarm rpt_cat, count dummy ;

The , after rpt_cat says that you want to summarize count for each level of rpt_cat.

 

Since you didn't actually have any values associated with rep_cat it was, I believe, defaulting to an N statistic as the variable rpt_cat is character and that is the default statistic for character (hard to sum character variables...)

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 92 views
  • 1 like
  • 3 in conversation