BookmarkSubscribeRSS Feed
SASPhile
Quartz | Level 8
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 _2008:);
yr_2009=sum(of _2009:);
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;
1 REPLY 1
Cynthia_sas
SAS Super FREQ
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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 1 reply
  • 732 views
  • 0 likes
  • 2 in conversation