sas数据集输出到excel文件利器——%sastoxl
发布:sakunamary | 分类:SAS软件培训
关于本站
人大经济论坛-经管之家:分享大学、考研、论文、会计、留学、数据、经济学、金融学、管理学、统计学、博弈论、统计年鉴、行业分析包括等相关资源。
经管之家是国内活跃的在线教育咨询平台!
获取电子版《CDA一级教材》
完整电子版已上线CDA网校,累计已有10万+在读~ 教材严格按考试大纲编写,适合CDA考生备考,也适合业务及数据分析岗位的从业者提升自我。
TOP热门关键词
SOURCE:sastoxl.sasPURPOSE:TopourthecontentsofaSASdatasetintoaMSExcelspread-sheetusingDDE.Theresultingspreadsheetreceivessomebasicformattingandissavedtoaspecifiedlocation.Valuesareenteredwiththeirforma ...
免费学术公开课,扫码加入![]() |
PURPOSE: To pour the contents of a SAS data set into a MS Excel spread-
sheet using DDE. The resulting spreadsheet receives some basic
formatting and is saved to a specified location. Values are
entered with their formats applied, whenever there is one
defined on the data set. An existing Excel file can be written
to, rather than a blank document. Custom sheetnames are sup-
ported, either existing ones or new ones ...
CREATED: 08DEC1999 by Koen Vyverman
MODIFIED : 31DEC2000 by Koen Vyverman
Re-wrote some of the macro decision code in a more canonical
form that will ensure proper SASv8 functioning.
04JAN2001 by Koen Vyverman
Added quite a slab of code to take care of custom sheet-names
in the output spreadsheet. Introduced some long filenames in
the process, so this now no longer works with SAS v6.12 and
earlier ... Can be easily repaired though if necessary.
In the same go, removed all traces of the early WAPTWAP me-
thodology for resolving macro-variables before throwing them
at the DDE-link. Now, resolution is forced by means of dummy
text-variables (see DDECMD and MACCMD in the code ...)
USAGE : Macro parameters :
libin (required): SAS library where the input SAS data set
lives.
dsin (required): Name of the SAS data set (part of) which
needs to be dumped into Excel format.
cell1row (optional): The row number of the first cell of the XL
spreadsheet where data should be inserted.
i.e. the upper left corner of the output
data range.
Default = 1.
cell1col (optional): The column number of the first cell of the
XL spreadsheet where data should be in-
serted.
i.e. the upper left corner of the output
data range.
Default = 1.
nrows (optional): The number of rows/observations to be in-
serted. If none is specified, an attempt
will be made to insert all observations
into XL.
Needless to say, this number needs to be
smaller than the maximal number of rows
supported by Excel...
ncols (optional): The number of columns/variables to be in-
serted. If none is specified, an attempt
will be made to insert all variables into
XL.
Needless to say, this number needs to be
smaller than the maximal number of columns
supported by Excel...
tmplpath (optional): The full path to the directory where the
Excel spreadsheet resides to which the
data needs to be written. To be used in
conjunction with TMPLNAME. If none is spe-
cified, a standard new XL workbook will be
used. Do _not_ end the path with a back-
slash character.
tmplname (optional): The filename of the Excel workbook in the
directory specified by TMPLPATH to which
the data needs to be written. To be used
in conjunction with TMPLPATH. If none is
specified, a standard new XL workbook will
be used. Do _not_ end the name with a .xls
filename extension.
sheet (optional): The name of the worksheet within the Excel
workbook to which the data will be writ-
ten. When left blank, this defaults to a
name of the form 'SheetN' where N is the
smallest available positive integer not
yet in use in the Excel workbook. Just try
some, pretty cool :-)
savepath (optional): The full path to the directory where the
finalized Excel workbook needs to be
saved. May be used independently from
SAVENAME. Do _not_ end the path with a
back-slash character.
Default = c:\temp
savename (optional): The filename by which the finalized Excel
workbook should be saved in the directory
specified by SAVEPATH. May be used inde-
pendently from SAVEPATH.
Default = SASTOXL Output
stdfmtng (optional): Standard formatting flag. Off by default.
Give a value of 1 to turn on. This will
apply some basic formatting to the
inserted data. The label row will be bol-
dened. Font will be set to Courier. Column
width will be set to best fit. Freeze
panes will be turned on for the label row.
EXAMPLE: 1) Suppose the data set WORK.SOMETHNG needs to be exported to
an Excel spreadsheet, and saved as 'c:\temp\Some data.xls'.
The data should end up in a worksheet with the default name
'Sheet1', and have the standard formatting applied to them.
To accomplish this, submit the following macro call:
%sastoxl(
libin=work,
dsin=somethng,
savepath=c:\temp,
savename=Some Data,
stdfmtng=1
);
2) Suppose only the first 125 rows of data set WORK.SOMETHNG
need to be exported to an existing Excel spreadsheet, and
saved as 'c:\temp\Some data.xls'. Suppose the full path and
name of the document in which the data need to be inserted
is 'n:\sasok\data\blank dox\Serious Fun.xls', and the block
of data is wanted at row 37, column 3 of a worksheet named
'Stuff from SAS'. If 'Stuff from SAS' does not exist yet on
'Serious Fun.xls', then it should be added as an extra sheet.
To accomplish this, submit the following macro call:
%sastoxl(
libin=work,
dsin=somethng,
cell1row=37,
cell1col=3,
nrows=125,
tmplpath=n:\sasok\data\blank dox,
tmplname=Serious Fun,
sheet=Stuff from SAS,
savepath=c:\temp,
savename=Some Data,
stdfmtng=1
);
CAVEAT : Specifying either TMPLPATH or TMPLNAME without the other will
result in both values being reset to their default settings. As
a consequence, a standard new document will be used.
Specifying a SHEET that already exists on the target workbook
will result in the content thereof (if any) being at least
partially over-written by the exported SAS data. Pay attention.
The names of worksheets in an Excel workbook are _not_ case
sensitive, even if they look as if they are because one is
allowed to use mixed case in the naming. The same goes for the
filenames under Windows by the way ...
「经管之家」APP:经管人学习、答疑、交友,就上经管之家!
免流量费下载资料----在经管之家app可以下载论坛上的所有资源,并且不额外收取下载高峰期的论坛币。
涵盖所有经管领域的优秀内容----覆盖经济、管理、金融投资、计量统计、数据分析、国贸、财会等专业的学习宝库,各类资料应有尽有。
来自五湖四海的经管达人----已经有上千万的经管人来到这里,你可以找到任何学科方向、有共同话题的朋友。
经管之家(原人大经济论坛),跨越高校的围墙,带你走进经管知识的新世界。
扫描下方二维码下载并注册APP
免流量费下载资料----在经管之家app可以下载论坛上的所有资源,并且不额外收取下载高峰期的论坛币。
涵盖所有经管领域的优秀内容----覆盖经济、管理、金融投资、计量统计、数据分析、国贸、财会等专业的学习宝库,各类资料应有尽有。
来自五湖四海的经管达人----已经有上千万的经管人来到这里,你可以找到任何学科方向、有共同话题的朋友。
经管之家(原人大经济论坛),跨越高校的围墙,带你走进经管知识的新世界。
扫描下方二维码下载并注册APP
您可能感兴趣的文章
人气文章
本文标题:sas数据集输出到excel文件利器——%sastoxl
本文链接网址:https://bbs.pinggu.org/jg/ruanjianpeixun_sasruanjianpeixun_135840_1.html
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。



