View previous topic :: View next topic
|
Author |
Message |
new2cobol
New User
Joined: 04 Jan 2006 Posts: 77 Location: Bangalore
|
|
|
|
I have to read a file in SAS and extract a value in SAS.
The file is of the format:
AB_DATE=20061011
AB_FILENAME=ABC.CDF.EFGH.FILE
AB_DIR=/ABC/DEF
etc...
Now I need to extract the file name, which has the key AB_FILENAME.
the pice of code I tried was,
Code: |
INPUT file DLM = '=' DSD;
INPUT @4 Key $ Value $;
|
Now, when I select value for the key = 'FILENAME' (I had to put @4 because SAS does not recognise '_' ) i get the value as the first 8 charecters of the name.
I tried
Code: |
INPUT file DLM = '=' DSD;
INPUT @4 Key $. Value $CHAR18.;
|
Which gave me an error, and
Code: |
INPUT file DLM = '=' DSD;
INPUT @4 Key $ Value $18;
|
Which returned only 1 charecter!
How can I get the whole file name in the variable??
HELP!!! |
|
Back to top |
|
|
manyone
New User
Joined: 09 Mar 2006 Posts: 9
|
|
|
|
//* you need the LENGTH statement at the beginning to specify field sizes
//SAS EXEC SAS
//INP DD *
WORD=VALUE
AB_DATE=20061011
AB_FILENAME=ABC.CDF.EFGH.FILE
AB_DIR=/ABC/DEF
//SYSIN DD *
DATA INP;
LENGTH KEY $16 VALUE $16;
INFILE INP DLM='=' DSD;
INPUT KEY $ VALUE $;
PROC PRINT;
// |
|
Back to top |
|
|
new2cobol
New User
Joined: 04 Jan 2006 Posts: 77 Location: Bangalore
|
|
|
|
Thanks!!!
I found the solution in another way... I dropped all lines which did not have FILENAME in the key, and declared length for key and value.
Code: |
INPUT @4 KEY $ @;
IF KEY ~= 'FILENAME' THEN DELETE;
INPUT @4 KEYNAME $.
VALUE $ 14-80. ;
|
And did the rest of the processing, but thanks a lot!!!
Always open to learn something new..... |
|
Back to top |
|
|
|