Hi
I got a problem when I practise using "output out=" . The dataset I'm using is sashelp.shoes, which is about shoes sale in the world, and contains many different regions (africa, asia,europe ...). I want to make a table which can summerize the sales based on regions (africa, asia,europe ...), this is my codes:
proc means data= sashelp.shoes ;
var total sales ;
by region;
output out=Regional_sales SUM(total sales)=reginal_sales;
run;
but it didn't work, the log says:
ERROR: Variable TOTAL not found.
why ?
thanks.
Your mixing up a variable label and the variable name. Total sales is the variable label.
Proc contents will show the label and name.
Labels are used to control a variable display name in reports and such, names are used in coding and have more restrictions.
Because there's no variable called Total in SASHELP.SHOES.
Run a proc contents on your dataset to see the variable names.
There is no variable named "Total" in sashelp.shoes.
I should change in your program:
var sales;
output out=Regional_sales SUM(sales)=total_regional_sales;
Shmuel
If you only want the output data set you might consider using Proc Summary or use the NOPRINT option with Proc Means to suppress the display tables.
yes, i tried it, works just like proc means(+noprint). thanks a lot.
Thank Reeza and Shmuel, your suggestions seem right, but still have some questions:
1, when I use PROC CONTENTS to check variable names, no "total sales" was found indeed, only saw "sales", but the dataset "sashelp.shoes" in my computer does clearly show "Total Sales" instead of "Sales" (see the attached picture 1).
2, when I used following codes as you suggested, it seemed working, which shows a table format exactly as I want, but the problem remains: "Total Sales" again, not the one I expected (ie, total_regional_sales) (picture 2).
proc means data= sashelp.shoes ;
var sales ;
by region;
output out=Regional_sales SUM(sales)=total_regional_sales;
run;
this problem seems bizzare, "Total Sales" seems very dominate in my computer, I wonder if my computer is virus infected.
any more idea?
thanks again. Mike
Your mixing up a variable label and the variable name. Total sales is the variable label.
Proc contents will show the label and name.
Labels are used to control a variable display name in reports and such, names are used in coding and have more restrictions.
thanks master, you solved my problem.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.