BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
BCNAV
Quartz | Level 8

I am creating a dataset for an Excel pivot table with respect to revenue from airlines. There are cases where an airline has no flights for a month, and hence no revenue. I'd like there to be a forced count of 0 for the month and 0 for revenue. I have this code from proc means:

 

PROC MEANS DATA=EGTASK.REVENUE
	NOPRINT	CHARTYPE
	NOLABELS
	NWAY
	
		SUM NONOBS 	;
	VAR amount;
	CLASS name /	ORDER=UNFORMATTED ASCENDING;
	BY Year Month;

OUTPUT 	OUT=EGTASK.REVENUE_BY_CLIENT_MONTHLY
	
		SUM()=

	/ AUTONAME AUTOLABEL  WAYS INHERIT
	;
RUN;

What ends up happening is that the top 6 clients (called name above) from the previous year are tracked during the current year. If there is a month where there are no observations for a client (called name) then they should be set to 0 for both flight counts and revenue totals.

 

thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
You can use a CLASSDATA to indicate the levels you like to have in the report.

View solution in original post

3 REPLIES 3
ballardw
Super User

If you want to use Proc Means then you will have to add the zero values into the data set if you want the mean to treat the value as 0 for means calculations.

 

Or perhaps you might want the year and month as class variables and use COMPLETETYPES on the proc statement to force values for months without any actual observations to appear in the output. Not really very clear what you actually expect.

Reeza
Super User
You can use a CLASSDATA to indicate the levels you like to have in the report.
BCNAV
Quartz | Level 8

CLASSDATA dataset does it!  Thanks!

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 540 views
  • 0 likes
  • 3 in conversation