How can I protect my excel file with a password, because in sas EG not supported DDE.
I'm using this, but I dont have the convert.vbs, so where can i get it?
/***********************************************/
/* Create a test worksheet to password protect */
/***********************************************/
ods tagsets.excelxp file="c:\temp.xml";
proc print data=sashelp.class;
run;
ods tagsets.excelxp close;
/*****************************************************************/
/* Create and excecute a script file using the input XML file */
/* and the converted XLSX file. The value 51 is needed for XLSX. */
/* Use the value of 1 for XLS files in the SaveAs command. */
/*****************************************************************/
%let XMLfile = c:\temp.xml;
%let ExcelFile = c:\temp.xlsx;
%let VBscript = ***c:\convert.vbs***;
%let password=test;
data _null_;
file "&vbscript" lrecl=200;
put 'Dim xlApp, xlWkb, SourceFile, TargetFile';
put 'Set xlApp = CreateObject("excel.application")';
put 'SourceFile="' "&XMLfile" '"';
put 'Set xlWkb = xlApp.Workbooks.Open(SourceFile)';
put 'TargetFile="' "&ExcelFile" '"';
put 'xlApp.DisplayAlerts=false';
put "xlWkb.SaveAs TargetFile, 51,""&password""";
put 'xlApp.DisplayAlerts=true';
put 'xlWkb.close';
run;
options noxwait noxsync;
x "cscript ""&vbscript""";
It appears that your code creates the file c:\convert.vbs for you and then runs it. You just need to remove the asterisks so that it's a valid file path.
If you don't have DDE it's unlikely that code will work for you either.
The last line,
x "cscript ""&vbscript""";
Is a command to your operating system. Often if DDE is disabled, this type of functionality is also disabled. You can check this by examining the XCMD option.
proc options option=xcmd;
run;
If XCMD is enabled you'll see:
XCMD Enables the X command in SAS.
You can only change that setting at start up and sometimes need to be an administrator as well.
I am using EG based on a SAS 9.4.2.0 installation and am trying to string a set of proc reports together using ODS LAYOUT, then have the report generated from this form the tab of an Excel file using TAGSET.EXCELXP as so:
ods listing close;
ods tagsets.excelxp file='E:\myfolder\myfile.xml'
options(
frozen_rowheaders='no' sheet_interval='none' sheet_name='sheet1'
autofilter='all' autofilter_table='2');
ods layout gridded columns=2 rows = 2;
ods region;
proc report data = mydata1;
title = 'some title';
run;
ods region;
proc report data = mydata2;
title = 'some title';
run;
ods layout end;
ods tagsets.excelxp options(sheet_interval='none' sheet_name='sheet2');
ods layout gridded columns=2 rows = 2;
ods region;
proc report data = mydata1;
title = 'some title';
run;
ods region;
title = 'some title';
run;
ods layout end;
ods tagsets.excelxp options(sheet_interval='none' sheet_name='sheet3');
ods layout gridded columns=2 rows = 2;
ods region;
proc report data = mydata1;
title = 'some title';
run;
ods region;
proc report data = mydata2;
title = 'some title';
run;
ods layout end;
ods tagsets.excelxp close;
ods listing;
However I am getting both a warning that TAGSET.EXCELXP does not exist, but also an error that indicates SAS thinks my local drive for saving the Excel file to is a sub folder of the SAS config folder on the network.
What have I done wrong?
Thanks
If your E:\ path is a local path (meaning a local disk), then the SAS Server cannot see it. You'll need to instead write that to a path that the SAS Server can see. If you're not sure what paths the SAS Server can see, please contact your SAS administrator; depending on the installation the server may be able to see your normal network shares, or it may be limited to only certain locations.
If E:\ is mapped to a network share, you may need to submit the network share UNC path, usually \\organization\path\to\file\ structure or similar.
You can also use the Copy Files custom task in Enterprise Guide; see There and Back Again, and if you're in EG 7 you can do this from the Tasks->Data menu. This would work if you write the file to your SAS Server's local storage (such as in the work directory or other local directory) and then use the copy files task to your local drive.
I have many questions regarding the ODS system and am trying to educate myself. However, I am unable to do so as the SAS documentation example generates an error.
The documentation in question is Controlling Where Your Output Is Stored.
The very first example is, verbatim,
/* Specify the ODS output path */
filename odsout ".";
goptions reset=all;
ods _all_ close;
ods pdf path=odsout file="mygraph.pdf";
proc gchart data=sashelp.prdsale;
vbar Product / sumvar=actual;
title1 "First Quarter Sales in Canada";
where Quarter=1 and Country="CANADA";
run;
quit;
ods pdf close;
ods html; /* Not required in SAS Studio */
It appears that the "." in the filename statement is a place holder akin to "C:\your\file\path\here\".
I have replaced that with "C:\output". When I do this, I get the following error:
6 ods pdf path=odsout file="mygraph.pdf";
----
22
76
ERROR 22-322: Syntax error, expecting one of the following: ;, (, ANCHOR, AUTHOR, BACKGROUND, BASE,
BODY, BOOKMARK, BOOKMARKGEN, BOOKMARKLIST, BOX_SIZING, CLOSE, COLOR, COLUMNS, COMPRESS,
CONTENTS, CSSSTYLE, DISPLAY, DOM, DPI, EXCLUDE, FILE, FONTSCALE, GFOOTNOTE, GTITLE,
HOST, KEYWORDS, NAMED_DEST, NEWFILE, NOBACKGROUND, NOBOOKMARKGEN, NOBOOKMARKLIST,
NOCOLOR, NOCONTENTS, NOGFOOTNOTE, NOGTITLE, NOPDFNOTE, NOTOC, PACKAGE, PCL, PDF,
PDFMARK, PDFNOTE, PDFTOC, PRINTER, PS, SAS, SELECT, SGE, SHOW, STARTPAGE, STYLE,
SUBJECT, TEXT, TITLE, UNIFORM.
ERROR 76-322: Syntax error, statement will be ignored.
Am I doing something wrong or did the author of this example not compile before publishing?
It seem that path option is valid in ods html, but is not valid in ods pdf, but it doesn't matter because you can specify absolute path in file option.
ods pdf file="C:\temp\mygraph.pdf";
I only see results of my SAS programs in Log like:
16488 title '6';
16489
16490 ods html file = 'E:\Dev\ka\body1.html';
16491
16492
16493 proc means data=learn.blood;
16494 var RBC WBC;
16495 output out = means mean = M_RBC M_WBC;
16496 run;
It's not show any error, but I don't see results in html file.
How to turn on html output?
You may have the setting 'Show results as they are generated' off.
Check your preference settings.
Confirm your HTML file is created as well, though you may need to include a CLOSE before it is fully available.
ods html file = 'E:\Dev\ka\body1.html'
proc means data=sashelp.class;
var height weight;
output out=means mean=M_Height M_Weight;
run;
ods html close;
Works fine for me. I adapted your code slightly to test it:
ods html file="%sysfunc(pathname(work))\body1.html";
proc means data=sashelp.class;
var height weight;
output out=means mean=M_Height M_Weight;
run;
%put Your file has been output to: %sysfunc(pathname(work))\body1.html;
I am seeing results. Are you sure you have observations in your dataset and that there are no errors or warnings being printed to the log?
How to obtain value of estimated parameters in SAS (proc phreg) ? I have been searching syntax OUTPUT and baseline but they gives only value XBETA ets.
I'm not into statistics, so I'm just guessing what value you mean - here's an example I think could help you:
ods trace on;
ods output ParameterEstimates=work.my_estimates_dataset;
proc phreg data=sashelp.class;
model age = height;
run;
ods trace off;
This is using SAS Output Delivery System component of SAS/Base.
With ods trace on;, you'll see references to parts of procedure output in SAS log:
Output Added:
-------------
Name: ParameterEstimates
Label: Maximum Likelihood Estimates of Model Parameters
Template: Stat.Phreg.ParameterEstimates
Path: Phreg.ParameterEstimates
You can refer to those (usually by Name or Path) and store them in a table with ODS OUTPUT... statement.
Look for SAS ODS user guide for more.