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;
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;
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;
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.