r/datascience • u/rajeshbhat_ds • 6d ago
Statistics Anyway to read SAS code?
I have to implement the varclus procedure in Python (it's a hierarchical feature clustering algorithm). The goal is to replicate the SAS procedure exactly. Is there anyway I can read the SAS implementation. AI gives a gist in english but looks like the actual code is proprietary. Anyplace where I can find implementations in other languages?
18
Upvotes
22
u/Honest-Ease5098 6d ago
There is a python package to do it: https://github.com/jingtt/varclushi
I wrote an implementation in C about 10 years ago but don't have access to the source code anymore.
4
u/sonicking12 6d ago
The code for Proce Varclus is not public. So...you can try to replicate it by uploading the SAS manual, which has a section on the details. That could help you with the use of AI. Good luck.
Personally speaking, Proc Varclus is one of the very best things from SAS.
3
u/SoccerGeekPhd 5d ago
SAS is proprietary so there's an unavoidable versioning issue. Which version of SAS algorithm should be implemented? What if SAS updates their implementation? The requirements should be redefined to indicate what is necessary for acceptance of your implementation.
There are many good hierarchical clusterings in R, hclust is a commonly used one, others are faster or more flexible. One common issue with clustering algorithms is a requirement for a distance matrix. This puts a burden of O(n^2) memory on the method. I would favor use of a distance function call, or a sparse matrix that defaults to +Inf for points too far away.
2
u/AppalachianHillToad 6d ago
Look for a similar R package and then have your favorite AI tool port it over to Python. Make sure you’ve got a worked example or two to confirm that algos are implemented the same in R as they are in snake.
1
u/suubu-crtiv 4d ago
the source isn't public, but the SAS/STAT docs spell out the algorithm: split the cluster with the largest second eigenvalue, then reassign variables. Check your output against a SAS run on a small dataset.}
1
u/deepbrainchain-feng 17h ago
One thing that helps with replicating it exactly: the SAS docs describe VARCLUS as iterative splitting based on the second eigenvalue of each cluster, with reassignment steps in between, so the details that usually cause mismatches are the stopping rule (maxeigen) and whether you start from principal components or a centroid. I'd run both implementations on a small dataset and compare the cluster assignments and the 1-R2 ratios per variable, that tells you quickly where they diverge.
-2
u/marjose2 6d ago
Yes