As part of the SAS Enterprise Guide export as a step in process the outhput file location is very tedious to select. Is there any faster way to do it than clicking through all the folders on my harddrive for every export.
The path is shown but I am not able to edit the path or paste a path here:
And when i press browse I am still not able to paste a path:
Am I doing something wrong, missing a setting or is there some kind of workaround.
Temporary question to Joe:
Like this?
Here is the most basic example of a macro, that can export your tables as excel files:
%macro ExportExcel(path,file_name,tab_name);
proc export data=&tab_name
outfile="&path.&file_name..xlsx"
dbms=xlsx
replace;
run;
%mend;
You can just paste your path, or better yet, make it a macro variable using %let statement.
But depending on your needs you can make this macro way more complicated. You can put more than one table into a single .xlsx file on different sheets, using a sheet statement. You can export every table from a whole library. It really depends on what you want.
You should be able to paste a full path into the filename box, just as with any other "save" dialog. This certainly works with the current version (Enterprise Guide 8.3), but should work with older versions as well.
Related
We can capture macro(%test) executed code with the below snippet
filename mprint 'output-file-name.sas';
options MPRINT MFILE;
%test;
options NOMPRINT NOMFILE;
Is there a way to capture the SAS executed code with MFILE option when we have datasteps/proc calls between the macro calls.
Example:
%test;
data ...
set ...
...
run;
%test2;
proc sort data=...
run;
%test3;
Using some sort of wrapper code to put the above code in a macro and then use MFILE ?
Is there any automated standard approach ? I have to implement the solution at enterprise level.
If you have control over the code itself, then you can do it easily using either:
Alternate logging methods for the entire SAS log (proc printto, altlog startup option)
Wrap the entire code in a macro, then use options mfile
That requires you being able to edit the code, though. Given you've thought of the second, and are asking how, I assume you probably don't have control directly.
If you do not have control over the code but have control over the SAS system (for example, you're a SAS Administrator), then you have a few options, all related to capturing the entire log.
You can, again, use altlog option
Better, though, is the more advanced logging options using the SAS logging facility. This can be used to put pretty detailed logs from the workspace server, or even from base SAS itself if you're in an environment where users run base SAS interactively.
If you are using a SAS Workspace Server (Enterprise Guide, SAS Studio), then the latter option is very easy: you just need to change the Workspace Server's logging level to Debug, and modify the name of the file it outputs to such that you can make use of it (add to the name things like the username).
Do note that options mfile can be overridden by the user, unless you add it to the restricted options table.
I couldn't resolve this error where I'm specifying a path to a file. But it seems that the compiler cannot recognize it.
Please help
If SAS says the file doesn't exist then it is not there. Not surprising as that is a really strange name for a file.
Why would you name a file xlsx? That is the extension that Excel uses for workbooks. If it actually is an Excel workbook then why would you try to read it as if it was a simple text file?
Also note that it looks like your file explorer window is not showing you the full filename. None of the files in your picture have the extension part of the filename displayed. What is the full name for that file? Either turn on the display of the extension or use properties to see the real filename.
You cannot access an Excel file that way anyway, so this is using the wrong approach entirely. INFILE is for reading in text type files, not for reading in an Excel file. Assuming you're trying to import your data, this is what you're likely looking to do this:
proc import out=want datafile='c:\users\pi\Documents\xlsx.xlsx' dbms=xlsx replace; run;
PLEASE do not post code and log as images in the future. It makes it harder to help you and answer your question when we first have to type out your code or data.
Is there a way to run a sas program with an external 'header' file (similar to python? For example, in python I can put 'import var_names.py' at the top of main.py, and change what I want in var_names.py instead of having to alter main.py. Is there something similar for SAS? Thank you!
It sounds as though you are looking for the %include statement.
Official documentation:
http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/a000214504.htm
You can also re-use code in various other ways, e.g. by defining macros and saving them to an autocall folder, saving formats to catalogues, and custom data step functions (via proc fcmp).
I have a user of a SAS server that wants to be able to "zip" a file they are outputting from a SAS script, by programming the file "zip" into the same script.
I'm hesitant to enable XCMD to allow this to be done natively on the Linux server on which SAS runs. Does anyone know of an alternative way of doing this without enabling XCMD?
Depends on what they're doing.
If they're producing a .sas7bdat (SAS Dataset), then options compress=yes; (or =char) will compress the SAS dataset, some. It won't compress nearly as much as normal gzip compression.
If they're writing out a text file, there is a method of writing a zip file. In 9.4, this is production; see this doc page for more information. Basically you can write it like this:
filename myfile zip '//mydir/myfile.z';
and then write to it like a normal file. You likely could write other kinds of files out to this as well (HTML, for example), if you read them in as text files and write them back out line by line to a zip fileref; but there's not much information available on this at the moment as it is brand new.
Prior to 9.4, there was the SASZIPAM filename engine, which is officially unsupported and not suitable for production use. You may be able to use it similarly.
If they're writing a PDF or similar file, then probably there is no suitable method for doing so, unless you can use the zip filename engine by reading the pdf in with recfmt=n and writing back out to the zip that way; that seems very dangerous, though.
The best solution from my point of view if you aren't comfortable enabling XCMD would be to have SAS write out a batch file (so a .sh file in Linux I suppose) containing the zip instructions, and have the process that runs SAS execute that .sh file when it's done.
If your output goes to an ODS destination you can create an ODS package and include all output in zip file.
ods package open;
ods html package;
proc print data=sashelp.class;
run;
ods html close;
ods package publish archive properties(archive_name="class.zip" archive_path="\");
ods package close;
I don't have a UNIX install so I cannot test this with -NOXCMD.
In Unix, you can use SAS to write through a pipe like you would any other Unix process.
There are gov't data files: http://www.cdc.gov/EpiInfo/
Available in this weird SAS format. How can I convert them into XML/CSV, something much simpler that can be read by scripts/etc.???
I had the same problem, so i made a simple SAS data viewer. You download it from the downloads section here: http://code.google.com/p/sasquatch
It has alot of the same features as SAS Universal Viewer, but its still a work in progress.
You need to have Adobe AIR installed, you can get that on the adobe website.
Are the data in the SAS XPORT (.xpt) or .sas7bdat format?
For future reference, SAS XPORT files can be read and written using the 'SASxport' package for R (http://cran.r-project.org/web/packages/SASxport/index.html).
(Already posted this to superuser.com)
SAS Institute (the company that makes SAS) produces a viewer for SAS data sets.
Note that SAS program files usually have the extension .sas, whereas the data files themselves usually have the extension .sas7bdat.
(EDIT: I notice belatedly that your title says on a Mac, so this may not help much as I believe the tool is Windows only.)
Here a quick-and-dirty python five-liner to convert a SAS .xpt (aka XPORT) file to .csv
import pandas as pd
FILE_PATH = "(fully qualified name of directory containing file)"
FILE = "ABC" # filename itself (without suffix)
# Note: might need to substitute the column name of the index (in quotes) for "None" here
df = pd.read_sas(FILE_PATH + FILE + '.XPT', index=None)
df.to_csv(FILE_PATH + FILE + '.csv')
Hopefully this might help someone
JMP runs on MAC and can read sas files. Visit jmp.com for more information.
There are two parts to your question
1. Read these files
2. Convert these files
I looked into the link you shared there are no directly downloadable files, but I am assuming that you mean the files for windows.
For viewing you can use the folloiwng
a. SAS Universal viewer: https://support.sas.com/downloads/package.htm?pid=667
b. Use SAS on mac to directly read the files
For conversion you can do the following
a. Use SAS proc import to export and proc export to export the files feature,
b. Use third party softwares, e.g., DBMSCopy for this;
c. Download trial version of JMP and convert the files to desired format, e.g., CSV/txt etc and get done with it.