由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - 请教如何用VBA在excel环境运行SAS code
相关主题
请教:marketing analysis中EXCEL都用哪些功能啊?包子请问保险公司的R&D 的职位 tech interview 会问什么呢?
VBA在统计编程中的市场大不大?到底什么样的条件可以去硅谷大公司当Analyst啊
[合集] VBA在统计编程中的市场大不大?加州三藩,银行职位 Quantitative Analyst, SAS Developer, Data Analyst
哪里可以学到Visual Basic in Excel请问SAS BASE考试中12题的正确答案是什么?
C++还是房地产价格分析,选课建议工作求助求建议
SAS 讨论: 关于 open protected excel files 的问题[合集] 问一个SAS 从excel import数据的问题
信用卡公司用Excel做些什么?Import excel file to sas (the first 8 or more observations
excel一问新人报道,兼问SAS data set的问题
相关话题的讨论汇总
话题: dim话题: sas话题: set话题: select话题: new
进入Statistics版参与讨论
1 (共1页)
h******n
发帖数: 232
1
举个例子。
在c盘根目录下有个写好的test.sas。请问能不能在excel VBA里面运行一遍这个test.
sas, 不需要返回任何值。
拜谢!
g*********r
发帖数: 2847
2
Yes. But perhaps you need to have a specific SAS add-on installed. don't ask
me which add-on, I have no idea. Our IT guy did it for us.
h******n
发帖数: 232
3
我想add on我是有的。但是不知道VBA code怎么写。能麻烦你给我列个sample VBA
code么?
多谢!
h******n
发帖数: 232
4
再求一下答案,在线等。谢谢!
w********m
发帖数: 1137
5
Sub iomtest()
Dim swsSAS As SAS.Workspace
Dim rsSAS As New ADODB.Recordset
Dim obObjectFactory As New SASObjectManager.ObjectFactory
Dim obServer As New SASObjectManager.ServerDef
Dim cnnIOM As New ADODB.Connection
Dim xmlInfo As String
Dim fld As Field
Dim row As Long
Dim col As Long
obServer.MachineDNSName = "localhost"

'We Create a local SAS workspace
Set swsSAS = obObjectFactory.CreateObjectByServer("Workspace", True,
obServer, "myUserName", "myPassword")
'Run the SAS program at c:\ saspg\sasglforum.sas my
Dim obStoredProcessService As SAS.StoredProcessService
Set obStoredProcessService = swsSAS.LanguageService.StoredProcessService
obStoredProcessService.Repository = "file:C:\mysaspg"
obStoredProcessService.Execute "sasglforum", Parameters
‘Export the SAS data set to Excel
cnnIOM.Provider = "sas.LocalProvider.1"
cnnIOM.Properties("Data Source") = "c:\temp"
cnnIOM.Open
rsSAS.Open "sasgldata", cnnIOM, adOpenDynamic, adLockPessimistic,
ADODB.adCmdTableDirect
'Select the sheet sasglf and freeze the panes on the 2ndline
Worksheets("sasglf").Activate
Range("A2").Select
ActiveWindow.FreezePanes = True
If Not (rsSAS.BOF And rsSAS.EOF) Then
Worksheets("sasglf").Activate
Range("A1").Select
rsSAS.MoveFirst
row = 2
Do While Not rsSAS.EOF
ActiveSheet.Cells(row, 1).Select
For Each fld In rsSAS.Fields
ActiveCell.Value = fld.Value
ActiveCell.Next.Select
Next
row = row + 1
rsSAS.MoveNext
Loop
Range("A2").Select
End If
rsSAS.Close
Set rsSAS = Nothing
cnnIOM.Close
Set cnnIOM = Nothing
swsSAS.Close
Set swsSAS = Nothing
Set swmWM = Nothing
End Sub
g*********r
发帖数: 2847
6
Thanks LS.
I'm sorry I have been very busy these days and hopefully LS's codes work for
you.
I did such stuff about a year ago, using some help of google. I created a .
bat file and used SHELL function. I probably cannot write ready-to-run codes
as LS right now and I don't have time to test the codes out. Sorry about
that.
1 (共1页)
进入Statistics版参与讨论
相关主题
新人报道,兼问SAS data set的问题C++还是房地产价格分析,选课建议
SAS base questionSAS 讨论: 关于 open protected excel files 的问题
A VERY Tricky SAS question: Help Needed with Baozi信用卡公司用Excel做些什么?
SAS sampling的问题excel一问
请教:marketing analysis中EXCEL都用哪些功能啊?包子请问保险公司的R&D 的职位 tech interview 会问什么呢?
VBA在统计编程中的市场大不大?到底什么样的条件可以去硅谷大公司当Analyst啊
[合集] VBA在统计编程中的市场大不大?加州三藩,银行职位 Quantitative Analyst, SAS Developer, Data Analyst
哪里可以学到Visual Basic in Excel请问SAS BASE考试中12题的正确答案是什么?
相关话题的讨论汇总
话题: dim话题: sas话题: set话题: select话题: new