Help using Base SAS procedures

proc report output off

Accepted Solution Solved
Reply
Contributor
Posts: 69
Accepted Solution

proc report output off

I am trying to get my proc report output to output the correct counts but it seems it is a bit off. Here is my code:

proc report nowd data=cardiac.mpinrestudyfinal (where =(prov_mpin = &prov_mpin2));

column ('Cardiac Metric Component' study)

('Calculation by Place of Service and Procedure' location )

,procedure count;

  define study / group ' ' order=formatted;

  define location / across ' ' order=formatted;

  define procedure / across ' ' style(column)={just=c};

  define count/ computed noprint;

  compute count;

    count=1;

  endcomp;

  quit;

I do have code the creates an rtf report prior. This is just the meat of my proc report. This is the data I have:

DATA HAVE
locationprocedurestudyPROV_MPINcount
OUTPATIENTCATH3-MONTH MAJOR RESTUDY RATE1045342
OUTPATIENTPCI1-30 DAY PCI REDO RATE1045341
OUTPATIENTPCI1-182 DAY PCI REDO RATE1045341
INPATIENTCATH3-MONTH MAJOR RESTUDY RATE6232561
INPATIENTTTE3-MONTH MINOR RESTUDY RATE6232561
OFFICE/CLINICTTE3-MONTH MINOR RESTUDY RATE6232561
OFFICE/CLINICTTE3-MONTH MINOR RESTUDY RATE6232561
OUTPATIENTCATH3-MONTH MAJOR RESTUDY RATE6232561
OUTPATIENTPCI1-30 DAY PCI REDO RATE6232561
OUTPATIENTPCI1-182 DAY PCI REDO RATE6232561
OUTPATIENTPCI1-182 DAY PCI REDO RATE6232562
OUTPATIENTCATH3-MONTH MAJOR RESTUDY RATE6232561

When I run this report, it outputs the attached information.


Accepted Solutions
Solution
‎10-06-2013 04:57 PM
SAS Super FREQ
Posts: 8,743

Re: proc report output off

Hi:

  I don't understand how your program produced your attached output. To really figure this out, someone needs to look at ALL your data and ALL your code, including your ODS statements. And, there seems something off in your code or off in your data. Does your data have a COUNT variable or not? If the COUNT variable exists in your data (which seems to be the case), then why are you defining count as a COMPUTED variable? That doesn't make sense. And if you're calculating COUNT, why are you setting it to 1 for each report row and then making it NOPRINT.

  In a previous posting, you asked about a PROC REPORT example where you needed to have character variables nested -underneath- some ACROSS items. The technique I showed in THAT posting (https://communities.sas.com/message/176310#176310 ), is not applicable if you already have a COUNT variable, if that's the technique you were trying to follow.

  I suggest you read the documentation topic entitled "How PROC REPORT Builds a Report" for an idea of how the different operators (parentheses, and commas) are used with the different usages (DISPLAY, SUM, ORDER, GROUP). The bottom line is that if COUNT exists in your data, then you would not define it as a COMPUTED usage. You can nest the COUNT variable under LOCATION and PROCEDURE. See the attached example and screen shot of the output shown in Excel (based on the 12 rows that you posted). Note that since the data you showed only has 2 values for PROV_MPIN, my output only showed 2 tables, one for each value. I just used BY group processing instead of a WHERE= option. And, the output that you attached has different values for PROV_MPIN than what you posted. I don't see how you get "DATA NEED OUTPUT" versus "DATA HAVE OUTPUT" or whether that is what you're showing you WANT or whether that is the actual output you're generating.

  I'd recommend opening a track with Tech Support on this.

cynthia


program_and_output.png

View solution in original post


All Replies
Solution
‎10-06-2013 04:57 PM
SAS Super FREQ
Posts: 8,743

Re: proc report output off

Hi:

  I don't understand how your program produced your attached output. To really figure this out, someone needs to look at ALL your data and ALL your code, including your ODS statements. And, there seems something off in your code or off in your data. Does your data have a COUNT variable or not? If the COUNT variable exists in your data (which seems to be the case), then why are you defining count as a COMPUTED variable? That doesn't make sense. And if you're calculating COUNT, why are you setting it to 1 for each report row and then making it NOPRINT.

  In a previous posting, you asked about a PROC REPORT example where you needed to have character variables nested -underneath- some ACROSS items. The technique I showed in THAT posting (https://communities.sas.com/message/176310#176310 ), is not applicable if you already have a COUNT variable, if that's the technique you were trying to follow.

  I suggest you read the documentation topic entitled "How PROC REPORT Builds a Report" for an idea of how the different operators (parentheses, and commas) are used with the different usages (DISPLAY, SUM, ORDER, GROUP). The bottom line is that if COUNT exists in your data, then you would not define it as a COMPUTED usage. You can nest the COUNT variable under LOCATION and PROCEDURE. See the attached example and screen shot of the output shown in Excel (based on the 12 rows that you posted). Note that since the data you showed only has 2 values for PROV_MPIN, my output only showed 2 tables, one for each value. I just used BY group processing instead of a WHERE= option. And, the output that you attached has different values for PROV_MPIN than what you posted. I don't see how you get "DATA NEED OUTPUT" versus "DATA HAVE OUTPUT" or whether that is what you're showing you WANT or whether that is the actual output you're generating.

  I'd recommend opening a track with Tech Support on this.

cynthia


program_and_output.png
Contributor
Posts: 69

Re: proc report output off

Yes, the prior post was when the data was formatted that way. But after QAing the output, I found the end results were not correct and had to change the code that gets me to my data have. I ended up having to recode about 13 pages that feed into my final data have information. I see your attached does work if I just had those 2 MPINS, but I have 27k mpins in my data have and have to figure out how to get that where statement right so the output will be correct. The reports are not an output of all the MPINS but only ones being asked for. So, someone might say I need only MPIN 1, 2 and 3. So, I have a let statement at the top for MPIN and state. This is because there is a ton of other data above this particular section. I only gave the 2 examples because 27k would have been far too much. I will read thru some output documentation and figure out how to output only a certain MPIN. I had the where(strata = &prov_mpin in there, but I think it needs to be defined in the ods and just noprint. Will try that and see what i get back. Thanks

Contributor
Posts: 69

Re: proc report output off

This works awesome. Thanks. I noticed that my data type was different in the data have for the prov_mpin. So, I had to do a let statement at the very beginning for that so I could select the MPIN to pull data on. Then, I did remove the total just because my manager and those reviewing the output do not want to see that. Thank you so much for your help.

*restudy breakout mpin;

proc report nowd data=cardiac.mpinrestudyfinal (where =(prov_mpin= &prov_MPIN2));

column('Cardiac Metric Component' study)

('Calculation by Place of Service and Procedure' location, procedure, count);

  define study /group ' ' order=formatted;

  define location / across ' ' order=data style(column)=[width=30%];

  define procedure / across ' ' order=data style(column)=[width=30%];

  define count / sum ' ';

  run;

ODS RTF CLOSE;

☑ This topic is SOLVED.

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

Discussion stats
  • 3 replies
  • 231 views
  • 0 likes
  • 2 in conversation