everyone.
I have established a shared folder with VM Virtualbox and uploaded a .sas7bdat data file. When I open SAS Studio to use the university edition, I can see this data file in "myfolders." However, when I try to print the contents or do anything with this data file, I constantly get errors.
Below is my current code to move this data file into my work library.
PROC IMPORT DATAFILE="/folders/myfolders/Lawrence.sas7bdat"
OUT=WORK.lawrence;
run;
Then, I get this error:
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
72
73 *data Lawrence;
74 *run;
75
76 PROC IMPORT DATAFILE="/folders/myfolders/Lawrence.sas7bdat"
77 OUT=WORK.lawrence;
ERROR: Unable to determine datasource type. Please use the DBMS= option.
What is the "option" to use for a .sas7bdat data file?
I just want to manipulate this data file. Thank you!
You don't import a SAS7bdat file, it's already in a SAS format. You can assign a libname and access the file directly.
libname myfiles '/folders/myfolders/';
proc print data=myFiles.Lawrence;
run;
Video tutorials are here: video.sas.com
Specific to this question: https://video.sas.com/detail/videos/sas-analytics-u/video/4664335810001/accessing-your-existing-data-in-sas-university-edition:-download-version?autoStart=true
Related
I'm trying to import a Stata version 13 file in my SAS 9.4 - but keep getting the error message
For Stata, Release flags of 103 to 115 are supported. You had -> 60
Requested Input File Is Invalid
ERROR: Import unsuccessful. See SAS Log for details.
Folliwing code does not work:
proc import out = uw14 datafile = "C:\User\KE14_hhld.dta"; run;
Neither does this: proc import out = uw14 datafile = "C:\User\KE14_hhld.dta"
dbms = stata replace; run;
I've found out that SAS 9.4 does not read Stata version 13 files. SAS 9.4 only reads Stata 12 files (or earlier).
One solution could be to save the Stata 13 file as an older version - but I only have Stata 12 on my computer and it's unable to open the version 13 file.
Another solution could be to save it as a CSV file in R - this done by following code:
proc import out = uw14 datafile = "C:\User\KE14_hhld.csv"; run;
But I've tried this and the transformation sets an unmanageable amount of my variables as characteristics instead of numeric and kills all formats.
Any other ideas?
(I'm not able to download other versions than SAS9.4 and Stata12)
Thanks
You can try to use R as a kind of third party. You can transform your dta into R data.frame and then write out the data.frame into .sas7bdat.
You can do all of this using the Haven package if I recall correctly. 2 or 3 lines of code should be sufficient:
Haven documentation
You can use stat/transfer for most type of data conversions: https://stattransfer.com
The title says it all. I have used the OUTPUTFMT=SVG in the ODS GRAPHICS statement without any problems in Base SAS, but this methods seems not to be appropriate for SAS Enterprise Guide.
If you look in the log you will see the issue:
27 ods graphics on / OUTPUTFMT=SVG;
28
29 proc reg data=test;
30 model y=x;
31 run;
WARNING: SASREPORT13 destination does not support SVG images. Using the default static format.
So it is the default output type that EG produces that is the problem. You can see that in the log as well:
15 ODS tagsets.sasreport13(ID=EGSR) FILE=EGSR
16 STYLE=HtmlBlue
17 STYLESHEET=(URL="file:///C:/Program%20Files/SASHome/SASEnterpriseGuide/7.1/Styles/HtmlBlue.css")
18 NOGTITLE
19 NOGFOOTNOTE
20 GPATH=&sasworklocation
21 ENCODING=UTF8
22 options(rolap="on")
23 ;
Got to Tools->Options. In the window select "Results General" and change to HTML as your results format.
Now when you run the code, you get HTML and SVG files produced. They will be in the GPATH location defined.
It does not look like the SAS HTML viewer is capable of displaying the SVG files. You will have to download them yourself and look at them.
NOTE: I'm using EG 7.1, but the file menu choices should be very similar.
I am a beginner level programmer in SAS and I am running into some issues trying to do LR.
I am trying to run a multivariate linear regression on a dataset (ads.csv, predicting sales based on the TV, radio, and newspapers figures)
S_no,TV,Radio,Newspaper,Sales
1,230.1,37.8,69.2,22.1
2,44.5,39.3,45.1,10.4
3,17.2,45.9,69.3,9.3
4,151.5,41.3,58.5,18.5
However when I run the linear regression in SAS using the initial coded to declare the output data, I get an error that saying : ERROR: Output SAS data set must be provided.
options linesize=180 pagesize=180 nodate pageno=1;
libname Linreg1 "/folders/myfolders";
proc import datafile="/folders/myfolders/ads.csv";
out=Linreg1.output dbms=dlm replace;
delimiter=,;
getnames=yes;
run;
Following is the complete log of this small piece of code :
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
55
56 options linesize=180 pagesize=180 nodate pageno=1;
57 libname Linreg1 "/folders/myfolders";
NOTE: Libref LINREG1 was successfully assigned as follows:
Engine: V9
Physical Name: /folders/myfolders
58 proc import datafile="/folders/myfolders/ads.csv";
ERROR: Output SAS data set must be provided.
NOTE: The SAS System stopped processing this step because of errors.
Any help would be greatly appreciated!
[Edit: as Reeza said in that first comment] There are extra semicolons in there - your proc import line needs to read as below:
options linesize=180 pagesize=180 nodate pageno=1;
libname Linreg1 "/folders/myfolders";
proc import datafile="/folders/myfolders/ads.csv" out=Linreg1.output dbms=dlm replace;
delimiter=,;
getnames=yes;
run;
I'm trying to move a SAS dataset over to our Linux server from a client. They created it on SAS 9.4, 64-bit on Windows 7. I'm using SAS 9.4, 64-bit on Linux.
If I do
proc datasets library=din;
run;
I get the following in my log
Libref DIN
Engine V9
Physical Name /sasUsr/DM/DATA/SAS_DATA/201510_SSI
Filename /sasUsr/DM/DATA/SAS_DATA/201510_SSI
Inode Number 46358529
Access Permission rwxrwxr-x
Owner Name cvandenb
File Size (bytes) 4096
Member File
# Name Type Size Last Modified
1 SAMPLE_FROM_SSI DATA 131072 09/14/2015 17:07:01
2 TEST DATA 131072 09/15/2015 09:35:59
15 run;
but when I do
data test;
set din.sample_from_SSI;
run;
I get
18 data test;
19 set din.sample_from_SSI;
ERROR: File DIN.SAMPLE_FROM_SSI.DATA does not exist.
20 run;
I also created a dummy dataset din.test and was able to proc print it. This seems to either be a version compatibility issue or transmission issue. I thought this would be straightforward. Any suggestions? I'm moving the file from windows to Linux with WinSCP. I'd rather not have to request a .csv and create the input statement, but will if I have to. Your help is appreciated.
Thanks,
Cory
If you are talking about an actual SAS dataset then make sure that the name of the file is in all lowercase letters and has the extension of .sas7bdat. If the source file from Windows did not have an extension of .sas7bdat then perhaps you are not dealing with a SAS dataset, but some other type of file.
In SAS code it does not matter whether you reference a dataset using upper or lower case letters. So you can reference a datasets as sample_from_SSI or Sample_From_Ssi to refer to the same file. The same is true of general filenames on a Windows machine. But on Unix system file names with different use of upper and lower case letters are distinct files. SAS requires that the filename of a SAS dataset must be in all lowercase letters.
So if you write:
libname DIN '/sasUsr/DM/DATA/SAS_DATA/201510_SSI';
proc print data=DIN.SAMPLE_FROM_SSI;
run;
Then you are looking to make a listing of the data in a file named:
/sasUsr/DM/DATA/SAS_DATA/201510_SSI/sample_from_ssi.sas7bdat
I usually get a note about CEDA in this case not missing data.
Create either a CPORT or XPORT file using the associated proc, PROC CPORT or XPORT and then move that file.
Try referring to the data with all caps as well, which I don't think should be the issue, but is possible.
I would try using PROC COPY directly on the libname, as you can select memtype=data that way without explicitly specifying the file.
If SAS still can't do that, then you might have a permissions issue or something else that is outside of the SAS realm I suspect.
Try using PROC CPORT and PROC CIMPORT.
Use the CPORT Procedure to convert the file into a transport file.
Use the CIMPORT Procedure to convert the transport file to a SAS format.
There is an example that sounds similar to what you are doing here.
According to SAS, the general procedure is:
A transport file is created at the source computer using PROC CPORT.
The transport file is transferred from the source computer to the target computer via communications software or a magnetic medium
The transport file is read at the target computer using PROC CIMPORT.
Note: Transport files that are created using PROC CPORT are not
interchangeable with transport files that are created using the XPORT
engine.
If that doesn't work, or it is taking a very long time to figure out, it would be faster to ask them for a CSV and import it directly using PROC IMPORT. It should read in quite easily, especially if it comes from PROC EXPORT.
I suddenly got an error message when exporting from SAS to Excel. I've been using the code below.
libname xls excel '..\Test.xlsx' ver=2007;
proc datasets lib = xls nolist;
delete Sweden;
quit;
data xls.Sweden;
set WORK.falcon_cases_2;
run;
libname xls clear;
This is what the log says:
NOTE: SAS variable labels, formats, and lengths are not written to DBMS tables.
ERROR: Execute: Unable to insert row
NOTE: The SAS System stopped processing this step because of errors.
NOTE: There were 4865 observations read from the data set WORK.FALCON_CASES_2.
WARNING: The data set XLS.Sweden may be incomplete. When this step was stopped there were 4864
observations and 14 variables.
ERROR: ROLLBACK issued due to errors for data set XLS.Sweden.DATA.
That's the error message I got. I've googled the error message and it seems like it usually indicates that the data set contains to many rows for Excel, 65 000 something. The data set I'm trying to export is only about 5500 rows.
Thanks for your help!
Things I would look into:
Funny characters. Excel might have had a transcoding problem if there are unicode characters in the data that don't transcode properly to wlatin1 (or whatever your default encoding is for Windows).
Disk space. Did your disk run out of space while running this?
Network or disk corruption. Is this replicable (does it occur if you try again)?
Can you try running that code on a basic dataset, like sashelp.class? Does that still cause the problem?