BookmarkSubscribeRSS Feed
OceanDream
Fluorite | Level 6

I'm trying to import a large CSV file into SAS. When I imported, I found that some variables were not imported properly. For example, there is a variable, which is a number. The range is [0, 1], i.e., the value is 0.0004. When I imported, it becomes a dummy variable, either 0 or 1. What can I do to get the original value??? Thanks in advance!

 

PROC IMPORT OUT= WANTED
DATAFILE= "HAVE.csv"
DBMS=CSV REPLACE;
GETNAMES=YES;
DATAROW=2;
RUN;

4 REPLIES 4
data_null__
Jade | Level 19

@OceanDream wrote:

I'm trying to import a large CSV file into SAS. When I imported, I found that some variables were not imported properly. For example, there is a variable, which is a number. The range is [0, 1], i.e., the value is 0.0004. When I imported, it becomes a dummy variable, either 0 or 1. What can I do to get the original value??? Thanks in advance!


Show the data.  Show the code.

ballardw
Super User

Look at several things. First is the CSV file and preferrably not using a spreadsheet program as most of those will make lots of assumptions about the data. Verify that the data is indeed 0.0004 or whatever.

 

Second is to add and supply a large value for guessingrows. By default SAS only examines a few rows to "guess" what the contents of a column may be. The first rows may have not been sufficient to note your decimals.

PROC IMPORT OUT= WANTED
DATAFILE= "HAVE.csv"
DBMS=CSV REPLACE;

Guessingrows = 32000;
GETNAMES=YES;
DATAROW=2;
RUN;

 

Third, look at the datastep code generated by proc import. It will tell you exactly what informat and format were assigned. You can copy the code and paste it into the editor and modify to make any desired changes such as changing informat or format, add labels and possibly get more useful variable names.

OceanDream
Fluorite | Level 6

ballardw, thank you very much! After I added "Guessingrows = 32000;", it works very well. you are right that SAS only uses a few rows to guess. And since my dataset has a lot of missing values, SAS just assumed it's a dummy variable. 

Reeza
Super User

@OceanDream Please mark the question answered if you have a solution. 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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
  • 1143 views
  • 1 like
  • 4 in conversation