how to resolve this Error: "physical file does not exist" - sas

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.

Related

SAS Enterprise Guide export as step in process path selection

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.

How do I edit files in Stata?

I'm using Stata 11 on OSX, new to Stata. Someone has sent me a .do file and I want to amend it and run it.
If I open the file in Stata (using File > Open), I see the file appear like this:
I can click on text, but I don't seem to be able to edit or select it. It's almost like an image rather than a text file.
So, um, how do I edit the text?
All of my Googling suggests I need to use the "do-file editor" - I'm not sure if this is it, and if so, how I set it to edit mode!
Open a new .do file (ctrl+9). Then in that go file>open and open the .do file in the editor. That should do the trick.

Cannot export Pandas dataframe to specified file path in Python for csv and excel both

I have written a program which exports my Pandas DataFrame to a csv as well as an excel file. However, the problem I am facing is that, randomly, the export function to both the file formats does not work, resulting in me seeing an error stating "No such File Path or Directory".
My code is as follows:
frame3.to_csv('C:/Users/Downloads/ABC_test.csv',index=False)
writer = pd.ExcelWriter('C:/Users/Downloads/ABCD.xlsx', engine='openpyxl')
frame3.to_excel(writer, sheet_name='Sheet1')
writer.save()
The major issue is that this code works sometimes and sometimes it does not! Going by what others have posted here, I tried to add the output directory by the use of
pth1 = os.path.join(r'C:/Users/Downloads/FinalProgram/', output_filename)
frame3.to_csv(pth1)
Sadly, this has no effect on this stubborn error. Would appreciate any help / insights possible on the matter.
Forgot to update - I figured a way around this particular problem:
Simply set the working directory for the program to be the output directory (as depicted by the command below), before the calling the 'to_csv' function.
os.chdir('F:/Codelah/')
On a side note, this was an issue I primarily faced on Windows OS - Ubuntu worked like a charm and did not require this workaround!
Hope this helps

Is there a way to zip a from from within a SAS script without enabling XCMD?

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.

How can I read/convert SAS Gov't Data files on a MAC?

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.