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
SAS Super FREQ
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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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