BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
danmen91
Calcite | Level 5

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!

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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

4 REPLIES 4
ballardw
Super User

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.

danmen91
Calcite | Level 5

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!

danmen91
Calcite | Level 5
iI figured it out, thanks!!
ballardw
Super User

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.

 

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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