Date: Thu, 29 Jan 2009 06:19:30 -0500
Reply-To: Nathaniel.Wooding@DOM.COM
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Nat Wooding <Nathaniel.Wooding@DOM.COM>
Subject: Re: Import CSV file to SAS
In-Reply-To: <fb3c0011-daef-475b-97b3-3ec6afd1e1a7@a12g2000pro.googlegroups.com>
Content-Type: text/plain; charset="US-ASCII"
The code in the reply below will not work for several reasons so I have
adjusted it a bit:
Data csv;
infile CARDS /* i just put the data here for convenience */
firstobs=3
dlm=',' dsd missover;
informat ClientName $50. Protocol $ 8. shortname $ 8.;
input ClientName Protocol ShortName StatusID StudyID ;
cards;
COL1,COL2,COL3,COL4,COL5
ClientName,Protocol,ShortName,StatusID,StudyID
ABC co ltd,ABC-3001,ABC3001,3,2314
DEF , D 123, D123, 4, 2256
RUN;
PROC PRINT;
RUN;
There should not be commas in the input statement (This was the result, I
assume, of cutting and pasting)
The length followed the input statement but by that time, the SAS
supervisor had already set protocol and shortname to be numeric variables
since there was no other information. I changed this to an informat and
placed it before the input statement.
Now, in these 100 CSVs, are there always the same variables and are they in
the same order?
Nat Wooding
Environmental Specialist III
Dominion, Environmental Biology
4111 Castlewood Rd
Richmond, VA 23234
Phone:804-271-5313, Fax: 804-271-2977
murugesh
<iammurugesh@GMAI
L.COM> To
Sent by: "SAS(r) SAS-L@LISTSERV.UGA.EDU
Discussion" cc
<SAS-L@LISTSERV.U
GA.EDU> Subject
Re: Import CSV file to SAS
01/29/2009 04:09
AM
Please respond to
murugesh
<iammurugesh@GMAI
L.COM>
On Jan 29, 8:05 am, "sukumarbalusw...@gmail.com"
<sukumarbalusw...@gmail.com> wrote:
> Hi,
>
> I'm having 100 CSV files.with the following 5 columns.
>
> Please help me how to import these, The first row is not important for
> me. I want to have the second row as a "Variable Name" in SAS Data
> Set. And my data starts from the 3rd row.
>
> eg of one CSV file.
>
> COL1,COL2,COL3,COL4,COL5
> ClientName,Protocol,ShortName,StatusID,StudyID
> ABC co ltd,ABC-3001,ABC3001,3,2314
> DEF , D 123, D123, 4, 2256
>
> Thanks in advcance.
>
> Regards,
> Sukumar
Hi Sukumar,
Please use the following code
data ex1;
infile 'C:\Documents and Settings\mp31795\Desktop\model.csv'
firstobs=3 lrecl=32767
dlm=',' dsd missover;
input ClientName $ ,Protocol,ShortName;
length ClientName $50. Protocol 8. shortname 8.;
run;
CONFIDENTIALITY NOTICE: This electronic message contains
information which may be legally confidential and/or privileged and
does not in any case represent a firm ENERGY COMMODITY bid or offer
relating thereto which binds the sender without an additional
express written confirmation to that effect. The information is
intended solely for the individual or entity named above and access
by anyone else is unauthorized. If you are not the intended
recipient, any disclosure, copying, distribution, or use of the
contents of this information is prohibited and may be unlawful. If
you have received this electronic transmission in error, please
reply immediately to the sender that you have received the message
in error, and delete it. Thank you.
|