DATA Step, Macro, Functions and more

proc report

Reply
Super Contributor
Posts: 673

proc report

Physician product year scripts
Mark Novo 2007 3000
Mark Novo 2007 4000
Mark Feib 2007 2500
Mark Novo 2008 2500
Twain Novo 2007 2000
Twain Novo 2008 3000
Twain Novo 2008 6000

How to generate the above data to following way ?


2007 2008
Physician Novo Feib Novo Feib
Mark 7000 2500 2500 -
Twain 2000 - 9000 -


The above can be achived using proc report.But I'm not able to get the prdoucts under year!
SAS Super FREQ
Posts: 8,866

Re: proc report

Hi:
You could try:
[pre]
COLUMN year, product, scripts;
or
COLUMN scripts, year, product;
[/pre]

AND, in the DEFINE statements, both YEAR and PRODUCT would be ACROSS variables and SCRIPTS would be a SUM variable.

cynthia
Super Contributor
Posts: 673

Re: proc report

Posted in reply to Cynthia_sas
> Hi:
> You could try:
> re]
> COLUMN year, product, scripts;
>
> COLUMN scripts, year, product;
> pre]
>
> AND, in the DEFINE statements, both YEAR and PRODUCT
> would be ACROSS variables and SCRIPTS would be a SUM
> variable.
>
> ynthia

Hi Cyhthia I tried this:

Physician product year scripts
Mark Novo 2007 3000
Mark Novo 2007 2000
Mark Feib 2007 2500
Mark Novo 2008 2500
Twain Novo 2007 2000
Twain Novo 2008 3000
Twain Novo 2008 4000


PROC REPORT DATA = novo_fieba NOWINDOWS HEADLINE;
COLUMN physician,year, product, scripts;
define physician/display;
DEFINE year / across;
DEFINE product/ across;
define scripts/sum;
run;

The idea is to display physician's name and in each year how much scripts for each product:

2007 2008
Physician Novo Feib Novo Feib
Mark 3000 2500 2500 -
Twain 2000 - 7000 -
SAS Super FREQ
Posts: 8,866

Re: proc report

Hi:
No comma after physician:
[pre]
COLUMN physician year, product, scripts;
or
COLUMN physician scripts, year, product;

DEFINE physician / group;
DEFINE year / across;
DEFINE product / across;
DEFINE scripts / sum;
[/pre]

Sorry, my bad. I left physician out of the COLUMN statement.

cynthia
Ask a Question
Discussion stats
  • 3 replies
  • 113 views
  • 0 likes
  • 2 in conversation