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!

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 622 views
  • 0 likes
  • 3 in conversation