sas >> Importing CSV file into SAS (limiting # of records )

by Newbie » Thu, 06 Apr 2006 20:52:26 GMT

Hi all,
I am importing a large csv file(2 Gb) into sas using the infile
statement. Is there any way to read/write only a small number of
records (for e.g. 100) into SAS so that I can check my dataset and make
sure all my formats have been correctly laid out and I am reading in
the file correctly.
Thanks in advance



sas >> Importing CSV file into SAS (limiting # of records )

by Jiann-Shiun.Huang » Thu, 06 Apr 2006 21:01:06 GMT


Newbie:

Add Obs=100 to the infile statement to have the first 100
observations.

J S Huang
1-515-557-3987
fax 1-515-557-2422

Hi all,
I am importing a large csv file(2 Gb) into sas using the infile
statement. Is there any way to read/write only a small number of
records (for e.g. 100) into SAS so that I can check my dataset and
make
sure all my formats have been correctly laid out and I am reading in
the file correctly.
Thanks in advance



sas >> Importing CSV file into SAS (limiting # of records )

by Don » Thu, 06 Apr 2006 21:03:33 GMT

* usually use the ;

OPTIONS OBS= 100; * at the location I wish to start limiting. Usually
the top;


* I am doing the above I place this at the bottom;
* am usually developing in EG so this is important.
options obs=2147483646 ;



Importing CSV file into SAS (limiting # of records )

by Don » Thu, 06 Apr 2006 21:06:02 GMT

* I usually use the ;

OPTIONS OBS= 100; * at the location I wish to start limiting. Usually
the top;


* If I am doing the above I place this at the bottom;
* I am usually developing in EG so this is important.
options obs=2147483646 ;



Importing CSV file into SAS (limiting # of records )

by Rickards, Clinton (GE Consumer Finance) » Thu, 06 Apr 2006 21:12:33 GMT

Don,

Using options obs=max; is easier to remember and will work in all environments.

Clint

-----Original Message-----
From: SAS(r) Discussion [mailto: XXXX@XXXXX.COM ]On Behalf Of Don
Sent: Thursday, April 06, 2006 9:04 AM
To: XXXX@XXXXX.COM
Subject: Re: Importing CSV file into SAS (limiting # of records )


* usually use the ;

OPTIONS OBS= 100; * at the location I wish to start limiting. Usually
the top;


* I am doing the above I place this at the bottom;
* am usually developing in EG so this is important.
options obs=2147483646 ;


Importing CSV file into SAS (limiting # of records )

by Newbie » Thu, 06 Apr 2006 21:37:43 GMT

Thanks, Don. That worked great. I just used OPTIONS OBS= 100 at the
top.
I tried using the oBS option earlier but I could not get it to work.
User error, I guess.
Thanks a lot for your help



Importing CSV file into SAS (limiting # of records )

by Newbie » Thu, 06 Apr 2006 21:43:05 GMT

Thanks, Don. That worked great. I just used OPTIONS OBS= 100 at the
top.
I tried using the oBS option earlier but I could not get it to work.
User error, I guess.
Thanks a lot for your help



Importing CSV file into SAS (limiting # of records )

by GADI_B » Thu, 06 Apr 2006 22:03:09 GMT

Add an OBS=n to your infile statement and it will stop after n observations

Gadi

-----Original Message-----
From: SAS(r) Discussion [mailto: XXXX@XXXXX.COM ] On Behalf Of Newbie
Sent: Thursday, April 06, 2006 2:52 PM
To: XXXX@XXXXX.COM
Subject: Importing CSV file into SAS (limiting # of records )

Hi all,
I am importing a large csv file(2 Gb) into sas using the infile statement. Is there any way to read/write only a small number of records (for e.g. 100) into SAS so that I can check my dataset and make sure all my formats have been correctly laid out and I am reading in the file correctly.
Thanks in advance


Importing CSV file into SAS (limiting # of records )

by Don » Thu, 06 Apr 2006 23:17:00 GMT


Clint.....

Thanks on the =MAX value.

Did not know that.......



Similar Threads

1. any rule of importing .csv file to SAS data

2. Importing CSV file format into Sas

Dear All:
  I am importing a CSV file format into SAS.  The values of one of the
variables is "01-JUN-2006 16:00:00" and when I import the file, SAS gives
an error and the import is unsuccessful. My presumption is that SAS does
not "like" the space in the value of this variable.  Are there any
suggestions for me to allow importation, perhaps by separating the the
values into two variables:  date -- "01-JUN-2006" and time -- "16:00:00".
Is there any code available for this procedure.
            Thanks

3. Import CSV file to SAS

4. Record lost after importing delimited file into SAS (while it

Just read the access file using SAS/ PC files , or save excel file as .csv
file and read using import data wizard in case you have just base SAS. Thats
the fastest way.

I think you should expand the right most side column length size (ag =10  or
members =9 ) depending on how your data is .

HTH.

Ajay

www.decisionstats.com


On Wed, Jun 11, 2008 at 10:46 PM, Irin later < XXXX@XXXXX.COM > wrote:

> I imported a bunch of soutce text tilde delimited files into SAS 9.1
> The problem is that for a couple of files SAS read just 14 records while I
> have 15  !!!!! One record is lost
> When I imported source file into Access or Excel  It showed exactly 15
> records.
> I tried to read data directly from the source tilde delimited file , but
> try as I might, I was unable to identify any problem in the data
> (actually it is hard to evaluate/read tilde delimited file manually.
> Honestly , I do not know how to do it)
> So far I wonder why Access (as well as Excel) was able to read all records
> while SAS could not.
> Actually I have a bunch of files and the following code worked just fine
> with an exception of a couple of files.
> data IP_r;
>     infile 'p:\Irin\temp\200801_IP_R.txt'
>     delimiter = '~' MISSOVER DSD lrecl=32767 firstobs=3;
>     length nm $12
>            end_period_id 8
>            nm_type $25
>            region $23
>            members 8
>            ag 8 ;
>     input  nm end_period_id nm_type region members ag ;
> obsnum + 1;
> run;
>
> log  did not complain and gave me the following notes:
> NOTE: The infile 'p:\Irin\temp\200801_IP_R.txt' is:
>       File Name=p:\Irin\temp\200801_IP_R.txt,
>       RECFM=V,LRECL=32767
> NOTE: 14 records were read from the infile
>       'p:\Irin\temp\200801_IP_R.txt'.
>       The minimum record length was 341.
>       The maximum record length was 389.
> How can I find what was wrong? Could you please give me a hand?
> -What can I do to identify a problem in data which caused that different
> approach ?
> OR
> -what can be fixed in my SAS code to avoid that confusion?
> Thank you in advance,
> Irin
>

5. Record lost after importing delimited file into SAS (while it is

6. Problem with importing from a csv file

Hello again

I have a .csv file with two columns, named CORE and CLUSTER. Core is a character field, cluster is numeric.  The first few lines of CORE are 6 characters long e.g.

00614D
08185C
08394B
08545A

but later on, they are longer, e.g.,
BW27011a
BW28011a
BW29011a
BW31011a
EN20101A
EN20102A


(Yes, I know, that's a terrible way to write a variable, but it was due to it being input over a period of 25 years or so, from machines that required certain formats, which differed over time....)

I am importing it into SAS using

PROC IMPORT OUT= WORK.twoclust
            DATAFILE= "C:\Fivelead\Data\twoclust.csv"
            DBMS=CSV REPLACE;
     GETNAMES=YES;
     DATAROW=2;
RUN;


and this is creating two variable, appropriately CORE and CLUSTER, but CORE is formatted as $6.  This causes major problems, because the first 6 characters of CORE are not unique.

Two questions:
1) How can I fix this?
2) Isn't this a horrible bug?

Thanks in advance

Peter

PS I will also write to SAS tech support about this.


Peter L. Flom, PhD
Statistical Consultant
www DOT peterflom DOT com

7. proc import .csv file question!

8. Import CSV file, variable field numbers

Dear SAS-L

I need to import a comma delimited file where there could be anything
between 1 and 5 additional rows of data after the original item. The data
is title information - a catalogue extract - and each new record
begins "ISBN: ". Following this there is a blank line then DETAIL1-3, then
another blank line and if there are more details then DETAIL4-6, or
otherwise there will be a new record again beginning "ISBN: ".

I've used this sort of syntax in the past but how can I get it to check
whether to create a new record or additional detail data?

<sascode>
data test;
retain ISBN det1 det2 det3 det4 det5 det6 email web;
infile "&path\Docs\CSV\_list.csv" dlm = ',' dsd missover firstobs = 1;
informat det1 8. det2 $60. det3 $30. email web $50. det4 $100. det5 det6
$20.;
input det1 det2 $ det3 $ det4 $ det5 $
/ j1 $ j2 $ j3 $ det6 $ email $
#3 j4 $ j5 $ j6 $ j7 $ web $;
drop j1 j2 j3 j4 j5 j6 j7;
run;
</sascode>

TIA.