DATA Step, Macro, Functions and more

Which SAS procedure to use to create reports with different variable formats?

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 17
Accepted Solution

Which SAS procedure to use to create reports with different variable formats?

Hi,

I would like to create a final report for each doctor as follows:

 

Doctor A

 

Metric                                      2001           2002            2003

----------------------------------------------------------------------

Hours worked                       2,540           5,789            3,274

Avg pts seen per day               1.25           5.25            0.65

Compensation                      $2001         $2002            $2003

 

<<another completely separate report for Doctor B>>

 

 

I currently have created individual datasets for each metric, normally using proc freq with a "by" statement or proc means with a "by" statement. I have been manually inputting the value of each proc freq or proc means for each doctor into an excel file to look like the above. However, my boss just informed me that my list of doctors has grown to over 100, so doing this manually is not going to work!

 

 

 

I've been reading up on PROC REPORT, PROC TEMPLATE and even PROC PRINT. However, My problem is is that the data years (e.g., 2011) have different formats depending on the metric (e.g., some times I need to format with a dollar sign, other times it's a straight number and other times I need commas to express thousands), so merging by data year is not going to work in a data step.

 

Does anyone have any suggestions?


Accepted Solutions
Solution
‎12-08-2016 10:46 PM
Super User
Posts: 19,822

Re: Which SAS procedure to use to create reports with different variable formats?

Posted in reply to sharonlee

If you have a file with metrics and doctor then:

 

1. Convert all your values to character using PUT and the explicit format of interest.

2. Sort by doctor and metric - you may need to add in an order variable for metric to get the exact order you want. 

3. Use PROC PRINT with a BY DOCTOR to get each doctors report printed into Excel.

View solution in original post


All Replies
Super User
Posts: 11,343

Re: Which SAS procedure to use to create reports with different variable formats?

Posted in reply to sharonlee

I would suggest going further back in your process. Describe the content of the starting data before you do your "metrics". Best would be to provide some example data for at least 2 doctors and at least 2 years (which can be partial, the idea to to let us know what the data looks like). Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn a data set into datastep code that can be pasted in the forum or attached as a text file so we can recreate the data and run code.

 

From the results I see, if the data were one record per patient with doctor name, date, payment and time then this could likely be accomplished directly in either proc tabulate or report

Occasional Contributor
Posts: 17

Re: Which SAS procedure to use to create reports with different variable formats?

Hi Ballardw,

The data are from a bunch of different datasources. I massage each dataset to come up with what I displayed.

Solution
‎12-08-2016 10:46 PM
Super User
Posts: 19,822

Re: Which SAS procedure to use to create reports with different variable formats?

Posted in reply to sharonlee

If you have a file with metrics and doctor then:

 

1. Convert all your values to character using PUT and the explicit format of interest.

2. Sort by doctor and metric - you may need to add in an order variable for metric to get the exact order you want. 

3. Use PROC PRINT with a BY DOCTOR to get each doctors report printed into Excel.

Occasional Contributor
Posts: 17

Re: Which SAS procedure to use to create reports with different variable formats?

This worked well. To make things look pretty, I outputed using ODS. Thanks!

☑ This topic is solved.

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

Discussion stats
  • 4 replies
  • 183 views
  • 0 likes
  • 3 in conversation