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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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
  • 1 reply
  • 279 views
  • 1 like
  • 2 in conversation