LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (March 2011, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Sun, 27 Mar 2011 14:13:39 -0400
Reply-To:     Peter Flom <peterflomconsulting@MINDSPRING.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Peter Flom <peterflomconsulting@MINDSPRING.COM>
Subject:      Reading numeric data from a CSV file as if it was categorical
Content-Type: text/plain; charset="us-ascii"

Hello

I have to read in data from 17 large (each is many megabytes) csv files. They have some columns where the data is really categorical, but where the vast majority uses numerical codes, but somewhere (hundreds of lines in) there is text data.

Of course, this makes SAS complain

Ordinarily, I'd fix all this up in Excel. But with so many large files that would be a major PITA. So, how can I tell SAS that some columns should be categorical

I wrote a mini-macro to read in the files:

%macro imp(filename);

PROC IMPORT OUT= WORK.&filename

DATAFILE= "C:\personal\Consults\Olivia Dixon\&filename..csv"

DBMS=CSV REPLACE;

GETNAMES=YES;

DATAROW=2;

RUN;

%mend imp;

%imp(file1);

And I then use it on 17 files.

TIA as always

Peter Flom

Peter Flom Consulting

http://www.statisticalanalysisconsulting.com/

http://www.IAmLearningDisabled.com


Back to: Top of message | Previous page | Main SAS-L page