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 | ||||
location | procedure | study | PROV_MPIN | count |
OUTPATIENT | CATH | 3-MONTH MAJOR RESTUDY RATE | 104534 | 2 |
OUTPATIENT | PCI | 1-30 DAY PCI REDO RATE | 104534 | 1 |
OUTPATIENT | PCI | 1-182 DAY PCI REDO RATE | 104534 | 1 |
INPATIENT | CATH | 3-MONTH MAJOR RESTUDY RATE | 623256 | 1 |
INPATIENT | TTE | 3-MONTH MINOR RESTUDY RATE | 623256 | 1 |
OFFICE/CLINIC | TTE | 3-MONTH MINOR RESTUDY RATE | 623256 | 1 |
OFFICE/CLINIC | TTE | 3-MONTH MINOR RESTUDY RATE | 623256 | 1 |
OUTPATIENT | CATH | 3-MONTH MAJOR RESTUDY RATE | 623256 | 1 |
OUTPATIENT | PCI | 1-30 DAY PCI REDO RATE | 623256 | 1 |
OUTPATIENT | PCI | 1-182 DAY PCI REDO RATE | 623256 | 1 |
OUTPATIENT | PCI | 1-182 DAY PCI REDO RATE | 623256 | 2 |
OUTPATIENT | CATH | 3-MONTH MAJOR RESTUDY RATE | 623256 | 1 |
When I run this report, it outputs the attached information.
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
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
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
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;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.