07-05-2016 01:00 AM
I am trying to import a CSV file in SAS Base 9.4. I have tried both Proc import and import wizard but I am getting just '1' in the place of dates and by default its taking text format. I tried format but I get error saying I can not use format.
The data in csv is something like this( this is dummy example just for reference). Funniest part is SAS is interpreting the last date column correctly but not the first one.
|135||1955/8/2 0:00||erg||4734||1997/3/11 0:00|
Apart from import wizard I used following code
proc import datafile = "Chjkj.csv"
out = c11
dbms = csv
getnames = yes;
Thanks in advance !
07-05-2016 02:05 AM
Is there any solution for this problem also....
even after using getnames=yes, my SAS table does not take the variable names from CSV file, instead it names it VAR1 VAR2... and so on.
07-05-2016 10:57 PM
I have found the reason of this weird behaviour. My Variable names are in Japanese, my program read it correctly when I changed them in source CSV. However, even the Japanese version of SAS is not reading the Japanese fonts and naming them as var1 var2 ... and so on. If you have any idea of how to solve this problem, please tell me.
07-05-2016 11:08 PM
How was the CSV file created? What encoding was used? Did SAS properly detect the encoding? Are the characters consistent with the encoding?
Can you post an example file with 2 or 3 columns and 3 or 4 rows?
07-08-2016 03:14 AM
Assuming you know the encoding you can specify it on the infile statement.
Heres a link on how to find your encoding.
07-05-2016 11:13 AM
GETNAMES assumes the variable names are on the first row. If for some reason they aren't then you'll get that behavior and possibly some variables that should be numeric end up character as the name is treated as a data value.
Also a good diagnostic when using proc import for delimited files is the log. It will contain the datastep code generated to read the data.
Sometimes it is best to copy the code from the log and modify to your needs such as setting consistent lengths for similar variables, especially if you are going to combine datasets, spellings of variable names and it often is a good idea to add variable labels.
07-05-2016 01:15 AM
Also, when you use proc import look at your log. It has the data step code. Copy that to your editor and edit the fields that aren't being imported properly.
You can copy the code without line numbers by pressing ALT+highlighting the code without line numbers.
07-05-2016 01:19 AM
your code does not have problem, tried same and working fine.
Check if all your sas components are installed correctly i.e SAS/ACCESS and SAS/CONNECT
proc import datafile = "C:\Users\ak26\Desktop\Book1.csv"
out = c11
dbms = csv
|The SAS System|
Need further help from the community? Please ask a new question.