BookmarkSubscribeRSS Feed
SASPhile
Quartz | Level 8
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!
3 REPLIES 3
Cynthia_sas
SAS Super FREQ
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
SASPhile
Quartz | Level 8
> 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 -
Cynthia_sas
SAS Super FREQ
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

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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