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

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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