Hello
I need to import CSV file into SAS.
The file contain delimiter # between fields.
I want to add a condtion as following:
1-If there is a row without delimiter # then Don't import this row
2-If First column contain char data then Don't import this row
What is the way to do it please?
DATA ttt;
LENGTH
F1 8
F2 8
F3 8
F4 8
F5 8
F6 8
F7 8
F8 8
F9 8
F10 $ 26
F11 8
F12 8
F13 $ 21328
F14 $ 84
F15 $ 2816
F16 $ 81
F17 $ 45
F18 $ 51
F19 8
F20 $ 1 ;
FORMAT
F1 BEST12.
F2 BEST9.
F3 BEST9.
F4 BEST4.
F5 DDMMYY10.
F6 DDMMYY10.
F7 BEST17.
F8 BEST16.
F9 BEST3.
F10 $CHAR26.
F11 BEST4.
F12 BEST9.
F13 $CHAR21328.
F14 $CHAR84.
F15 $CHAR2816.
F16 $CHAR81.
F17 $CHAR45.
F18 $CHAR51.
F19 BEST9.
F20 $CHAR1. ;
INFORMAT
F1 BEST12.
F2 BEST9.
F3 BEST9.
F4 BEST4.
F5 DDMMYY10.
F6 DDMMYY10.
F7 BEST17.
F8 BEST16.
F9 BEST3.
F10 $CHAR26.
F11 BEST4.
F12 BEST9.
F13 $CHAR21328.
F14 $CHAR84.
F15 $CHAR2816.
F16 $CHAR81.
F17 $CHAR45.
F18 $CHAR51.
F19 BEST9.
F20 $CHAR1. ;
INFILE '/path'
LRECL=21476
ENCODING="HEBREW"
TERMSTR=CRLF
DLM='7F'x
MISSOVER
DSD ;
INPUT
F1 : ?? BEST32.
F2 : ?? BEST9.
F3 : ?? BEST9.
F4 : ?? BEST4.
F5 : ?? DDMMYY10.
F6 : ?? DDMMYY10.
F7 : ?? COMMA17.
F8 : ?? COMMA16.
F9 : ?? BEST3.
F10 : $CHAR26.
F11 : ?? BEST4.
F12 : ?? BEST9.
F13 : $CHAR21328.
F14 : $CHAR84.
F15 : $CHAR2816.
F16 : $CHAR81.
F17 : $CHAR45.
F18 : $CHAR51.
F19 : ?? BEST9.
F20 : $CHAR1. ;
RUN;
I think this may work: add the _INFILE_ option to the infile statement and test on that:
INFILE '/path'
LRECL=21476
ENCODING="HEBREW"
TERMSTR=CRLF
DLM='7F'x
MISSOVER
DSD
_INFILE_= test;
length testcol1 $8;
input testcol @; /* input COL 1 */
if not index(test,'#') then delete; /* no delimiters */
if findc(testcol,,1,'A') then delete; /* characters in first column */
drop test:;
input @1 /* and then the rest of the program, inputting from first position again */
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.