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 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

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