BookmarkSubscribeRSS Feed
deleted_user
Not applicable
How do I use existing variables in a calculation without having to use them in the ODS output?

Example:

Var3=var1/var2;

I only want to use var3 on my ODS output. How do I do that?
1 REPLY 1
Cynthia_sas
Diamond | Level 26
Hi:
You need to use the NOPRINT option for the variables. You still need them in a COLUMN statement:

[pre]
column name var1 var2 var3;
[/pre]

because they have to be available to PROC REPORT so it can do the division, but the NOPRINT option on the DEFINE statement -- just "hides" them:
[pre]
define name / order;
define var1 /sum noprint;
define var2 /sum noprint;
define var3 / computed;
compute var3;
var3 = var1.sum/var2.sum;
endcomp;
[/pre]

Just be sure that var1 and var2 are listed BEFORE var3 on the column statement. That's because PROC REPORT fills up the report row from LEFT to RIGHT. So they have to be listed in the COLUMN statement BEFORE var3.

cynthia

[/pre]

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 save with the early bird rate—just $795!

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
  • 918 views
  • 0 likes
  • 2 in conversation