BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Salah
Quartz | Level 8

Hello

 

Does SAS have HarmonicNumber? When I looked this up,  I only found "Harmean" function, but this calculates the mean of vector of size n. 

I tried to take n=1,  unfortunately, this didn't work.

In my problem, I derived the log-likelihood function using Mathematica and then I used the output in my code (see pic below).1.JPG

Thank you

 

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

I hesitate to correct Mathematica, but I thought Harmonic Numbers were only defined for integers. The arguments do not look like integers to me.

 

I don't think SAS has a built-in function for harmonic numbers. However, the harmonic numbers are just the sum of the reciprocals of integers, so you can define the following function:

proc iml;
start HarmonicNumber(n);
   return sum(1/(1:n));
finish;

/* test it: The 10th harmonic number is 7382/2520 */
H = HarmonicNumber(10);
print H[format=FRACT.];

View solution in original post

1 REPLY 1
Rick_SAS
SAS Super FREQ

I hesitate to correct Mathematica, but I thought Harmonic Numbers were only defined for integers. The arguments do not look like integers to me.

 

I don't think SAS has a built-in function for harmonic numbers. However, the harmonic numbers are just the sum of the reciprocals of integers, so you can define the following function:

proc iml;
start HarmonicNumber(n);
   return sum(1/(1:n));
finish;

/* test it: The 10th harmonic number is 7382/2520 */
H = HarmonicNumber(10);
print H[format=FRACT.];

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!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

From The DO Loop
Want more? Visit our blog for more articles like these.
Discussion stats
  • 1 reply
  • 577 views
  • 2 likes
  • 2 in conversation