- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I'm trying to infile rpt. file and i have problems with values that have blanks. Sas is giving me records from next column but I want him to show me the blank.
the file looks like this
5------10----
ab cd
1
null null
null null
4
no i want to infile it
informat ab $CHAR2
data test;
infile 'path/rpt.' missover;
@5 ab: $CHAR2.
cd:;
run;
and the result is
ab cd
1 1
null null
null null
4 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
When posting text where positioning is crucial, use the {i} button. The standard posting window eliminates leading blanks and the like, so your examples can't be used for testing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You might want to post a few records from your file by attaching a TXT file if the data isn't sensitive. Your data step is syntactically incorrect as posted as you do not include an INPUT statement to start reading unless that just got missed in pasting.
Approaches to reading this will vary depending on the actual text file structure. It may be that you want to use column input to read at specific columns for your variables for instance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
ive tried missover, pointers, and it is the same. Maybe because im infiling from rpt file not txt but im not sure
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
If you raw data file is arranged in fixed column locations then tell SAS that is what you want. So let's assume this is what your data file looks like:
----5----10---- ab cd 1 null null null null 4
Do not use the MISSOVER option instead use the TRUNCOVER option because it handles short lines better.
data want ;
infile xx truncover ;
input var1 $5-9 var2 $10-15 ;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
ok I know what is the problem
sas treats blank space as a delimiter so it goes to the next record and reads it.
I can use dsd option but then i have to use pointer for every column. Is there any other solution ? cause i have like 300columns.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Jedrzej wrote:
I can use dsd option but then i have to use pointer for every column. Is there any other solution ? cause i have like 300columns.
When reading a file in fixed width format you have to tell sas where each variable begins and how many chars belong to it.