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

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