Help using Base SAS procedures

problems importing database

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 6
Accepted Solution

problems importing database

Hi everyone,

 

I´m trying to import a database form a .csv, one of the variables contains the code of a route of public transportation, this code can be numeric or alphanumeric. When importing the database, SAS turns this variable into numeric and each alphanumeric observation is turned to missing value. I tried with proc import and i also tried importing with the option you find in file. I also tried

proc import datafile="E:\Datos_Historicos\Plan_Itinerarios_Historico.csv"
dbms=dlm
out=plan_itinierarios_2017
replace;
delimiter=',';
getnames=no;
DBDSOPTS= "DBTYPE=(var2='CHAR(20)' var7='CHAR(5)')";

run;

 But it seems DBDSOPTS doesn't work

 

How can i correct this?

 

THANK YOU!


Accepted Solutions
Solution
‎09-01-2017 11:38 AM
Super User
Posts: 13,498

Re: problems importing database

Use proc import as you have. The log will have the code of the data step. Copy that into the editor (remove any line numbers that may appear).

Change the informat for the variable/column from (likely best32. or similar) to $15. or something long enough to read all the characters.

Run the modified program.

Save the modified program especially if you are going to read similar files in the future. Then you change the infile to match the new data and change the name of the output data set.

View solution in original post


All Replies
Solution
‎09-01-2017 11:38 AM
Super User
Posts: 13,498

Re: problems importing database

Use proc import as you have. The log will have the code of the data step. Copy that into the editor (remove any line numbers that may appear).

Change the informat for the variable/column from (likely best32. or similar) to $15. or something long enough to read all the characters.

Run the modified program.

Save the modified program especially if you are going to read similar files in the future. Then you change the infile to match the new data and change the name of the output data set.

Occasional Contributor
Posts: 6

Re: problems importing database

I didn´t quite get it, I run the proc import, then i use

 

data WORK.PLAN_ITINIERARIOS_2017 ;
informat var7 $10.;
run;

 

what do I do next?

 

sorry!

Occasional Contributor
Posts: 6

Re: problems importing database

iI figured it out, thanks!!
Super User
Posts: 13,498

Re: problems importing database

If you search this forum for posts relating to Import Error or Import Problem you will find a large number of them are from using Proc Import without understaning the limitations and advantages.

 

 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 163 views
  • 0 likes
  • 2 in conversation