Hi everyone!
Please help!
I ran libname and imported a csv file to SAS, it converted to sas7bdat file but in the log it says import unsuccessful, and some lines with invalid data. I thought it was problem with the file so I tried to import another csv file that I know imported successfully on another computer but it still gave me the same error message, but again it was converted to a sas7bdat file.
I am not sure if I can use the sas7bdat file to do my programming or should I worry about some data in there not being the same as my original csv file??
Thanks!!
We need:
- example lines from the csv that do not successfully import
- your import code
- the log from importing the example lines
I attached the log that sas gave me after importing
@michan22 wrote:
I attached the log that sas gave me after importing
A log is simple text, please post it using the {i} icon.
MS Office files won't get through many firewalls because of the danger of malware.
And we need some example lines from the csv that cause your problems. Use the {i} icon for that, also.
You have several variables that are numeric. Example informat vl_12 best32. says that variable vl_12 is a numeric.
However it is trying to read values of <400. Which are not numeric. So you get an invalid data type.
Increasing GUESSINGROWS may help. The question is: should vl_12 be numeric or character? If you want it as numeric what value do you assign <400? and <499 and possibly other values? Also you already have many variables treating <400 as character.
Here is the other file that imported successfully on another computer...
import file:
PROC IMPORT OUT= QIAO.NOSOCOMIAL0327
DATAFILE= "D:\Nosocomial\NosocomialStudy_DATA_2017-03-26_035
3.csv"
DBMS=CSV REPLACE;
GETNAMES=YES;
DATAROW=2;
RUN;
@michan22 wrote:
I am not sure if I can use the sas7bdat file to do my programming or should I worry about some data in there not being the same as my original csv file??
No, you cannot use the file to do your progamming because it's only partially complete and the data is not correct.
Add the GUESSINGROWS statement into your PROC IMPORT code and make it big - as many rows as the data set has. It will slow down the import and may not get rid of all errors but should help.
Then take the data step code from the log, copy and paste that into a new editor window. Then look at your error messages. The one shown is:
NOTE: Invalid data for rec_cd4 in line 89 102-117.
In the data step code, find the INFORMAT, FORMAT and INPUT lines where this variable is referenced. Make sure the formats and informats are correct for the data you're trying to import. For example, SAS may think the variable is numeric, but it's really character so you need to change it to a character format.
It doesn't matter if a different file imports correctly on another system, every file is different. SAS should guess the same on each system but there are cases it won't due to differences in the file encodings, OS, different version or default settings.
Couple of thoughts
It is a tiny file so:
Do you now what applications created the CSV, it is generally better to work from the source apllication, like MS-Access or excel.
Not all transformations are perfectly reversible.
Does it import into Access or Excel. Access puts out some usefull messages?
Hi guys,
Thank you for the advice but it's still not working.
I tried to import the same file on a desktop and it works fine, but would not work on the laptop.
I have heard people having issues importing from some laptops. Does anyone know how to fix the issues? did I not install something properly?
If you're using SAS UE look at the TERMSTR option, especially if you're using multiple OS.
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.