Thursday
GreenCode
SAS Employee
Member since
06-23-2011
- 13 Posts
- 0 Likes Given
- 1 Solutions
- 4 Likes Received
-
Latest posts by GreenCode
Subject Views Posted 217 4 weeks ago 369 a month ago 664 a month ago 1347 04-09-2025 11:45 AM 448 04-09-2025 11:37 AM 2244 08-15-2024 11:36 PM 3964 04-21-2023 02:04 AM 2951 04-14-2023 10:11 AM 3997 04-14-2023 09:55 AM 1428 07-27-2022 10:54 AM -
Activity Feed for GreenCode
- Got a Like for Run LLM on Viya 4 locally. 4 weeks ago
- Posted Run LLM on Viya 4 locally on Developers. 4 weeks ago
- Posted Re: PROC OLLAMA, Running LLM Locally With SAS code on Developers. a month ago
- Got a Like for PROC OLLAMA, Running LLM Locally With SAS code. a month ago
- Posted Re: PROC OLLAMA, Running LLM Locally With SAS code on Developers. a month ago
- Posted PROC OLLAMA, Running LLM Locally With SAS code on Developers. 04-09-2025 11:45 AM
- Posted PROC OLLAMA过程,用SAS程序本地运行大模型 on 欢迎来到SAS中文社区!. 04-09-2025 11:37 AM
- Posted Re: PROC JIEBA 过程,在SAS调用JIEBA中文分词功能 on 欢迎来到SAS中文社区!. 08-15-2024 11:36 PM
- Posted Re: PROC JIEBA 过程,在SAS调用JIEBA中文分词功能 on 欢迎来到SAS中文社区!. 04-21-2023 02:04 AM
- Got a Like for Re: use java connect sas and run one spript.sas. 04-18-2023 10:09 PM
- Got a Like for Re: PROC JIEBA 过程,在SAS调用JIEBA中文分词功能. 04-18-2023 10:09 PM
- Posted Re: use java connect sas and run one spript.sas on 欢迎来到SAS中文社区!. 04-14-2023 10:11 AM
- Posted Re: PROC JIEBA 过程,在SAS调用JIEBA中文分词功能 on 欢迎来到SAS中文社区!. 04-14-2023 09:55 AM
- Posted sqlite libname 引擎 on 欢迎来到SAS中文社区!. 07-27-2022 10:54 AM
- Posted PROC JIEBA 过程,在SAS调用JIEBA中文分词功能 on 欢迎来到SAS中文社区!. 07-11-2022 05:31 AM
- Posted Re: clearing the cache in SAS on ODS and Base Reporting. 05-15-2008 01:39 AM
- Posted Re: import syntax on SAS Procedures. 05-14-2008 11:22 PM
-
My Liked Posts
Subject Likes Posted 1 4 weeks ago 1 04-09-2025 11:45 AM 1 04-14-2023 10:11 AM 1 04-14-2023 09:55 AM
4 weeks ago
1 Like
Because there no SAS/Toolkit for Viya 4 right now, so the PROC OLLAMA cannot be migrated to Viya 4. here is the python way to run LLM on Viya 4 locally by using python module llama-cpp-python. by default llama-cpp-python may be not installed on your Viya 4 system. because the PROC PYTHON are executed by the compute server pod which is a read-only file system, so you cannot install any python package on this pos directly. to bypass this restriction, need make some changes on compute service's configuration, which control the compute server's system environment created by it. suppose the you have nfs path /data/sascode mount to /sascode, can be viewed in SASStudio. create a sub folder pythonhome under /data/sascode. /data/sascode/pythonhome will become new python home folder. or use another writable persistent path instead.
1. go to SAS env. manager, edit the compute service sas.compute.server: startup_commands, add command export PYTHONHOME=/sascode/pythonhome
2. go to SAS env. manager, edit SASStudio compute context advanced attribute, add new attribute to allow run x, pipe SAS statement in SASStudio, name: allowXCMD, value: true
3. check compute server pod's OS by running SAS code:
filename oscmd pipe "cat /etc/os-release"; data _null_; infile oscmd; input; put _infile_; run;
4. install a host that OS is same as the compute server pod's OS, and install gcc related development packages, and sqlite-devel, libffi-devel.
5. check the current python version by run python code in SASStudio
6. download the version of python source code to the host build in step 4. create directory /data/sascode/pythonhome. go to python source folder, configure/make/install it with:
./configure --prefix=/data/sascode/pythonhome
make
make install
7. pip install llama-cpp-python huggingface_hub and other python module you want.
8. copy folder /data/sascode/pythonhome from the host to nfs host,
/data/sascode/pythonhome , then can be viewed in SASStudio
9. download model from https://huggingface.co/models to /sascode by using python code or clicking on the model file directly:
from llama_cpp import Llama
llm = Llama.from_pretrained( repo_id="ggml-org/gemma-1.1-7b-it-Q4_K_M-GGUF", filename="*.gguf", local_dir="/sascode", cache_dir="/sascode", verbose=False )
If you get python error that indicates permission error about /sascode/.cache_dir when run the python code above, run SAS code below then retry the donwloading code :
data _null_;
x "chmod -R /sascode";
run;
10. run the local downloaded LLM and save the result to WORK.RESULT:
import pandas as pd from llama_cpp import Llama llm = Llama( model_path="/sascode/gemma-1.1-7b-it.Q4_K_M.gguf", ) input_text = "Once upon a time" output = llm(input_text, max_tokens=50) print(output['choices'][0]['text']) #save result to WORK.RESULT df = pd.DataFrame({"rsult":[output['choices'][0]['text']]}); ds = SAS.df2sd(df, 'RESULT')
NOTES:
1. There might be a memory error. Increase the Compute podtemplate memory using the commands below:
kubectl -n viya annotate podtemplate sas-compute-job-config launcher.sas.com/default-memory-limit=64Gi --overwrite kubectl -n viya annotate podtemplate sas-compute-job-config launcher.sas.com/max-memory-limit=64Gi --overwrite
Also increase memsize in Environment Manager Contexts-> Compute context-> SAS Studio Compute context Enter following line to SAS option: -memsize max
2. If prompt python module not found, repeat above 7, 8 step
... View more
a month ago
The more people who need this module, the more likely it is that R&D will deliver it as soon as possible, so it is recommended that you or remind all customers who need it to send a request to SAS Technical Support for SAS/Toolkit for Viya 4
... View more
a month ago
Unfortunately, there is no SAS/Toolkit module under Viya right now, so this procedure does not work on Viya. It can be replaced by other methods, such as using x, pipe to execute the llama-cli command line to output the result to a file, and then read the result back from the file.
... View more
04-09-2025
11:45 AM
1 Like
PROC OLLAMA, a SAS procedure written using SAS/toolkit calls llama.cpp to run the large model locally(Windows 11 x64), details: analyserxyz/myrepo1: test
Example code:
options fullstimer; libname tmplib "c:\temp"; proc ollama out=tmplib.result; model "c:\temp\gemma-1.1-7b-it.Q4_K_M.gguf"; params "-no-cnv -ngl 99 -p ""Once upon a time"""; run;
Output:
... View more
04-09-2025
11:37 AM
PROC OLLAMA过程,用SAS程序本地运行大模型。利用SAS/toolkit写的SAS过程调用llama.cpp的功能在本地运行大模型,输出结果到数据集,目前只有Windows x64版,在SAS 9.4 M8, M9下可以运行,详细步骤请参考 analyserxyz/myrepo1: test
options fullstimer; libname tmplib "c:\temp"; proc ollama out=tmplib.result; model "c:\temp\gemma-1.1-7b-it.Q4_K_M.gguf"; params "-no-cnv -ngl 99 -p ""Once upon a time"""; run;
... View more
04-14-2023
10:11 AM
1 Like
Java连接SAS服务器提交SAS代码运行例子:
import java.io.BufferedOutputStream; import java.io.FileOutputStream; import org.omg.CORBA.StringHolder; import com.sas.iom.SAS.IBinaryStream; import com.sas.iom.SAS.IFileService; import com.sas.iom.SAS.IFileref; import com.sas.iom.SAS.ILanguageService; import com.sas.iom.SAS.IWorkspace; import com.sas.iom.SAS.IWorkspaceHelper; import com.sas.iom.SAS.StreamOpenMode; import com.sas.iom.SASIOMDefs.OctetSeqHolder; import com.sas.services.connection.BridgeServer; import com.sas.services.connection.ConnectionFactoryConfiguration; import com.sas.services.connection.ConnectionFactoryInterface; import com.sas.services.connection.ConnectionFactoryManager; import com.sas.services.connection.ConnectionInterface; import com.sas.services.connection.ManualConnectionFactoryConfiguration; import com.sas.services.connection.Server; public class DownloadOutput { /** * @param args */ public static void main(String[] args) { try { String classID = Server.CLSID_SAS; String host = "t3207.na.sas.com"; int port = 8591; Server server = new BridgeServer(classID, host, port); // TODO Auto-generated method stub ConnectionFactoryConfiguration cxfConfig = new ManualConnectionFactoryConfiguration( server); ConnectionFactoryManager cxfManager = new ConnectionFactoryManager(); ConnectionFactoryInterface cxf = cxfManager.getFactory(cxfConfig); String user = "sasdemo"; String password = "Orion123"; ConnectionInterface cx = cxf.getConnection(user, password); org.omg.CORBA.Object obj = cx.getObject(); IWorkspace sasWorkspace = IWorkspaceHelper.narrow(obj); IFileService fileService = sasWorkspace.FileService(); StringHolder outstring = new StringHolder(); IFileref fileRef = fileService.AssignFileref("out", "TEMP", "", "", outstring); ILanguageService languageService = sasWorkspace.LanguageService(); String sasCode = "goptions reset=all gsfname=out gsfmode=replace dev=pdf; proc gchart data=sashelp.class;vbar age / discrete;run;quit;"; languageService.Submit(sasCode); IBinaryStream fileStream = fileRef .OpenBinaryStream(StreamOpenMode.StreamOpenModeForReading); BufferedOutputStream fos = new BufferedOutputStream( new FileOutputStream("c:\\temp\\test.pdf")); boolean readMore = true; OctetSeqHolder tempData = new OctetSeqHolder(); while (readMore) { fileStream.Read(1024, tempData); if (tempData.value.length == 0) { readMore = false; } else { fos.write(tempData.value); } } fileStream.Close(); fos.close(); cx.close(); } catch (Exception e) { e.printStackTrace(); } } }
... View more
04-14-2023
09:55 AM
1 Like
不好意思,好久没来这里。是的,是用SAS提供的编程接口工具SAS/TOOLKIT来写的调用jieba功能的一个自定义过程步,具体的实现可看完整的源代码 https://github.com/SASAnalyser/PROC-JIEBA 和SAS/TOOLKIT 帮助文档 https://support.sas.com/documentation/onlinedoc/toolkit/p245.pdf
... View more
07-27-2022
10:54 AM
sqlite libname 引擎,可以通过libname语句直接访问sqlite数据库,目前只有Windows 64位版本,下载地址: https://github.com/SASAnalyser/PROC-JIEBA/releases/download/1.0/libname-sqlite_win_x64.zip
安装方法:下载上面文件解压到 <SASHome>\SASFoundation\9.4\core\sasexe 下面就可以,因为是静太连接sqlite库所以不需要安装sqlite。
使用方法如下,如果sqlite数据库文件不存在,将会创建一个:
/* write to sqlite database */
libname mylib sqlite "C:/temp/sample.db";
data mylib.air;
set sashelp.air;
run;
/* read from sqlite database */
libname mylib sqlite "C:/temp/sample.db";
data air;
set mylib.air;
run;
已知限制:目前不支持bulkload,不支持在Base SAS里直接打开sqlite数据表和看表属性,不支持sqlite的BLOB类型
... View more
07-11-2022
05:31 AM
利用SAS Toolkit写的一个过程步,可以在SAS代码中调用JIEBA中文分词功能,源代码在 https://github.com/SASAnalyser/PROC-JIEBA,可以执行文件: https://github.com/SASAnalyser/PROC-JIEBA/releases
需要Windows 或者Linux 下安装有64位 SAS 9.4 (Unicode 支持),例子:
data indata; format inword $char200.; input inword; datalines; 小明硕士毕业于中国科学院计算所,后在日本京都大学深造 ; run;
proc jieba data=indata out=outdata maxword=32; dictpath "C:\SASToolkit\cjieba\dict"; var inword; instr "我是拖拉机学院手扶拖拉机专业的"; run;
对indata里var 指定的变量如果没var则对所有字符变量分词和 instr指定的句子分词。
结果保存在 out 数据集,如果不指定 out 数据集则结果打印在日志窗口。
... View more
05-15-2008
01:39 AM
You can try following statement to un-assign libname:
libname db_name clear;
... View more
05-14-2008
11:22 PM
Hi,
You can refer to following link:
http://support.sas.com/documentation/onlinedoc/91pdf/sasdoc_913/base_proc_8977.pdf
... View more