BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Konkordanz
Pyrite | Level 9

Hi,

 

I want to compute a column within a proc-report-step. My question: Why is it necessary, to use aliases, if I want to calculate with two existing variables? For example:

In example #1 I tried to summarize invoice and msrp. That doesnt work.

In example #2 I gave these both variables aliases and referenced in the further steps always to these aliases. That works. But: Why? What is the background of these rule?

 

#1

proc format; value form 0, . ='-' other=[numx.15]; run; proc report data=sashelp.cars; columns origin make msrp invoice test; define origin/group; define make/group; define msrp / analysis format=form.; define invoice / analysis format=form.; define test/ computed format=form.; compute test; test=invoice+msrp; endcomp; run;
#2
proc report data=sashelp.cars; columns origin make msrp=ms invoice=inv test; define origin/group; define make/group; define test/ computed format=form.; define ms / analysis format=form.; define inv / analysis format=form.; compute test; test=inv+ms; endcomp; run;
1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

With a non-aliqsed analysis variable, you need to also use the required statistic:

proc format;
value form 
  0, . ='-' 
  other=[numx15.]
;
run;

proc report data=sashelp.cars;
columns origin make msrp invoice test;
define origin/group;
define make/group;
define msrp / analysis format=form.;
define invoice / analysis format=form.;
define test/ computed format=form.;
compute test;
  test = invoice.sum + msrp.sum;
endcomp;
run;

View solution in original post

1 REPLY 1
Kurt_Bremser
Super User

With a non-aliqsed analysis variable, you need to also use the required statistic:

proc format;
value form 
  0, . ='-' 
  other=[numx15.]
;
run;

proc report data=sashelp.cars;
columns origin make msrp invoice test;
define origin/group;
define make/group;
define msrp / analysis format=form.;
define invoice / analysis format=form.;
define test/ computed format=form.;
compute test;
  test = invoice.sum + msrp.sum;
endcomp;
run;

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 1 reply
  • 751 views
  • 1 like
  • 2 in conversation