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 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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