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
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.
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.
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;
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.
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.
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.