3 weeks ago - last edited 3 weeks ago
I'm trying to import a CSV file available on internet. This file is encoding in UTF- 8. There is a problem doing this because some column-names aren't taking into account (with °, é,... symbols as example) and the 2nd column have characters and numerics values.. So, character's are replaced by some points.
So, I build an empty dataset (with characters values for this second column) but I don't know how I can import this CSV file into this empty dataset, do you have any idea ? There is maybe a statement to add in proc import to write these data into my empty dataset ?
Thanks a lot,
3 weeks ago
First try using OPTIONS VALIDVARNAME=V7; This may fix your variable names.
There is no option in PROC IMPORT to insert data into existing empty table. You can use PROC APPEND with base as your empty table and data as your imported data or use INSERT INTO statements.
3 weeks ago
Thanks for your answer,
At the begining, I start with this:
filename elect url "http://www.regardscitoyens.org/telechargement/donnees/elections/2014_municipales/municipales-2014-r%C3%A9sultats-bureaux_vote-tour1.csv" encoding="utf-8"; /*OPTIONS VALIDVARNAME=V7;*/ proc import datafile=elect out=elect replace dbms=csv ;
delimiter = ";";
GETNAMES = YES; run;
Here is what I done for the emply table (sorry it's in French):
/*empty table*/ proc sql; CREATE TABLE empty ( numero num label="N° tour", dep char(3) label="Code département", code num label="Code commune", nom char(50) label="Nom de la commune", vote num label="N° de bureau de vote", inscrit num label="Inscrits", votant num label="Votants", exprimes num label="Exprimés", numliste num label="N° de dépôt de la liste", candidat char(20) label="Nom du candidat tête de liste", prenom char(20) label="Prénom du candidat tête de liste", codenuance char(10) label="Code nuance de la liste", voix num label="Nombre de voix" ); quit;
I try to Append it but columns names are different and so on it's not working.
In my mind, I prepare an empty base to give to the 2nd column a character type to be able to import all row of the CSV which is changing from numeric to charactere at the end.
I hope you can help me finding what I'm missing