BookmarkSubscribeRSS Feed
kekou
Calcite | Level 5

I have CSV data. Can anyone help reading it in SAS without using proc import?

6 REPLIES 6
art297
Opal | Level 21

If you run proc import SAS will write and run the data step that you would otherwise have to write to read in the file.

 

Proc import saves you the time of getting the variable names from the first records, determining which variables are numbers and which are characters, and identifying each variable's length.

 

Art, CEO, AnalystFinder.com

 

kekou
Calcite | Level 5

please without using proc import

art297
Opal | Level 21

If you run proc import it will not only do the job, but show you the code that answers your question. 

 

On the other hand, if you want a lesson, take a look at: https://support.sas.com/techsup/technote/ts673.pdf

 

Art, CEO, AnalystFinder.com

 

Vince_SAS
Rhodochrosite | Level 12

Why can't you use PROC IMPORT?

 

Vince DelGobbo

SAS R&D

Reeza
Super User

@kekou wrote:

i have a CSV data.  can anyone help reading it in SAS without using proc import?


Is this a file that should be public and available to anyone or does it contain confidential information? If this is a work file you may have violated confidentiality rules. 

Tom
Super User Tom
Super User

CSV files are easy to read. Something like your file with only three variables is easier to read WITHOUT using PROC IMPORT.

data want ;
  infile 'zipcode.csv' dsd truncover firstobs=2;
  input var1-var3 ;
run;

Now if you want you can use more meaningful names for your variables.

If it really was a messy file then you could try reading the fields as characters strings and adding extra code to convert the strings into the types of values you need.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 6 replies
  • 1305 views
  • 0 likes
  • 5 in conversation