sas >> [Q] How to Import DateTimes from a csv

by andymanme » Sat, 24 Mar 2007 06:35:34 GMT

Hi everyone,

Hope someone can help.

I have a csv file which looks like:

Var1,Var2
07/08/2006 05:56:22

So Var2 is dd/mm/yyyy with two spaces followed by hh:mm:ss

Could someone please tell me how to import this csv file. For example
when I use: File > Import Data ...

and copy the code from the log, SAS is just reading in the datepart
for that variable, i.e. the code in the log is:

data WORK.ImportedData;
%let _EFIERR_ = 0; /* set the ERROR detection macro variable */
infile 'C:\Book1.csv' delimiter = ',' MISSOVER DSD lrecl=32767
firstobs=2 ;
informat VAR1 $3. ;
informat VAR2 ddmmyy10. ;
format VAR1 $3. ;
format VAR2 ddmmyy10. ;
input
VAR1 $
VAR2
;
if _ERROR_ then call symputx('_EFIERR_',1); /* set ERROR
detection macro variable */
run;

Really hope someone can help, hope the question is clear!
Thank you in advance
Andy


Similar Threads

1. How to Import DateTimes from a csv

2. GUESSINGCOLUMNS: PROC IMPORT/IMPORT Wizard CSV/TAB/DLM

3. Problem with importing from a csv file

4. proc import .csv file question!

Hello, folks,

I use "proc import " to import the .csv file to SAS. I was lazy to
find the longest width for each categorical variables since the raw
file is too big (encounter data). And SAS maybe only read the first
12? variables to set the default variable length to this categorical
variable and that caused the truncation somehow.

So, I came here to ask if there is a good method to read large .CSV
files without truncation problems.

I appreciate your help very much!

5. Importing a CSV in to SAS

6. PROC IMPORT NUMBERS FROM A CSV EXCEL

I am importing a csv file with very large strings of numbers.  Actually
they are characters (although all numeric).  By the time it gets into
excel it is a number in scientific notation.  I want to then read that
into a SAS data set as a character field. =20

Thanks.
Paul Schwartz=20

*********************************************************************
This message and any attachments are solely for the
intended recipient. If you are not the intended recipient,
disclosure, copying, use or distribution of the information=20
included in this message is prohibited -- Please=20
immediately and permanently delete.

7. Import CSV file, variable field numbers

8. 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