DATA Step, Macro, Functions and more

nesting in proc report

Reply
Super Contributor
Posts: 673

nesting in proc report

I couldnt nest the variables product and year-month and product and year columns to get the display as shown below:

2008-01 2009-01 2008&2009 2008&2009
comp mydrug comp mydrug comp mydrug

data ex_trn1;
SET ex_trn;
yr_2008=sum(of _2008Smiley Happy;
yr_2009=sum(of _2009Smiley Happy;
run;

proc report list NOWINDOWS data=ex_trn1 HEADLINE MISSING;
COLUMN region bsm zip name adddress city _2008: ,product _2009:, product yr_2008, product yr_2009, product;
SAS Super FREQ
Posts: 8,864

Re: nesting in proc report

Hi:

I am confused by your question, because you say this is your desired result:
[pre]
2008-01 2009-01 2008&2009 2008&2009
comp mydrug comp mydrug comp mydrug
[/pre]

but you show many more variables than those above in your column statement:
[pre]
COLUMN region bsm zip name adddress city _2008: ,product _2009:, product yr_2008, product yr_2009, product;
[/pre]

I am confused by your use of "colon" syntax...do you have multiple variables like:
city_2008_1
city_2008_2
city_2008_3 or
product_2009_1
product_2009_2
product_2009_3
????

You can use colon syntax in a column statement, but it might not work the way you expect in an ACROSS situation. For example, if you had grpvar, var1 and var2 and numvar in a dataset, you -might- put:
[pre]
column grpvar var:,numvar;
[/pre]

However, in this situation, only VAR2 would be crossed with numvar...NOT VAR1 crossed with VAR2 crossed with NUMVAR. This is probably not what you want to happen. So, I'd recommend clarifying what your variables are and show some examples of the data and then examples of the desired output that show ALL the variables in the column statement in the desired output.

I'm also confused because this seems related to some of your other PROC REPORT and ACROSS questions, such as these previous postings:
http://support.sas.com/forums/thread.jspa?messageID=20472俸
http://support.sas.com/forums/thread.jspa?messageID=24565念
http://support.sas.com/forums/thread.jspa?messageID=20574偞
http://support.sas.com/forums/thread.jspa?messageID=23216媰
http://support.sas.com/forums/thread.jspa?messageID=20499倓
http://support.sas.com/forums/thread.jspa?messageID=20354侂

ACROSS still works the way explained previously. If you want to CALCULATE the 2008 column value + 2009 column value by adding information from 2 columns, you would have to use ABSOLUTE column names in a COMPUTE block in PROC REPORT.

I'd recommend trying a simple PROC REPORT with ACROSS without the colon syntax. Also, reread the previous forum postings on the use of ACROSS items in PROC REPORT and decide whether you need to calculate the 2008+2009 column info or whether your data is simple ACROSS data that doesn't need any further calculations.

cynthia
Ask a Question
Discussion stats
  • 1 reply
  • 104 views
  • 0 likes
  • 2 in conversation