BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I need calculate the product of a series of variables, for instance: var1 var2 ... var100, I need the product of var1-var100, instead of var1*var2*...*var100, is there a simple way to calculate that result?

I assume there should be some fuction to do that, just like the sum of var1-var100 could be done by sum(of var1-var100). I check function product but it doesn't seem the right way.

Greatly appreciate any suggestions and help!
1 REPLY 1
Patrick
Opal | Level 21
There is no product function as much as I know.

Some code like below might help:

data have;
var1=5; var2=3;
run;

%let prodlist=;
proc sql noprint;
select name into :ProdList separated by '*'
from dictionary.columns
where libname='WORK' and memname='TEST' and upcase(name) like 'VAR%'
;
quit;

data want;
set have;
product=&prodlist;
put product=;
run;

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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