I assume you have many variables and many observations to process. So transposing the data and using the SAS function HARMEAN would be impractical. Imagine transposing a data set with millions of rows!.
This isn't the most elegant solution but it gets the job done. With a little work I am confident that you can come up with an elegant solution for you specific problem.
I tried to mimic the harmean function in SAS. In the SAS documentation if any value is negative then the result is missing. And missing values need to be ignored.
set one end=eof;
if x <0 and not missing(X) then negative_flag+1;
if missing(x) then n=n-1;
if eof and not negative_flag then do;