BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
gwilli31
Calcite | Level 5

I am having trouble with a data set that I imported as a txt file. There are missing values represented with blanks, but sas is filling those values in with the next available value instead of ".". For example, the first line of observations is "1000 203 82 56 3.599999905 4.309999943 Buckingham 46 female 62 121 medium 118 59         29 38 720"; as you can see, there is a missing value between 59 and 29. However, sas scooted the 29 over into that cell instead of putting ".", and instead put "." in the last column for that observation. My data step is as follows: 

 

data diabetes;
infile diabetes DLM="09"x missover firstobs=2;
input
ID
chol
stab_glu
hdl
ratio
glyhb
location $
age
gender $
height
weight
frame $
BP_1s
BP_1d
BP_2s
BP_2d
waist
hip
time_ppn;
run;

 

Am I missing something in my code? I thought that missover would tell sas to put "." in for blanks, but it doesn't seem to be working 😞 help would be much appreciated!!! 

 

P.S. I attached the txt file below in case maybe the issue is something with the data file itself. 

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
data diabetes;
infile 'c:\temp\diabetes2.txt' DSD DLM="09"x truncover firstobs=2;
input
ID
chol
stab_glu
hdl
ratio
glyhb
location $
age
gender $
height
weight
frame $
BP_1s
BP_1d
BP_2s
BP_2d
waist
hip
time_ppn;
run;

You need DSD option.

View solution in original post

3 REPLIES 3
Ksharp
Super User
data diabetes;
infile 'c:\temp\diabetes2.txt' DSD DLM="09"x truncover firstobs=2;
input
ID
chol
stab_glu
hdl
ratio
glyhb
location $
age
gender $
height
weight
frame $
BP_1s
BP_1d
BP_2s
BP_2d
waist
hip
time_ppn;
run;

You need DSD option.

gwilli31
Calcite | Level 5
Thank you! It worked!!!!
Tom
Super User Tom
Super User

You need to include the DSD option so that adjacent tabs are taken as meaning there is an empty value. Otherwise multiple delimiters next to each other are treated as one delimiter.

infile diabetes DSD DLM="09"x truncover firstobs=2;

The default behavior is designed for reading data that is using space as the delimiter. In that case users like to use multiple spaces with short values so the text in the file lines up neatly.  This makes it easier for humans to review.  Note that without the DSD option you will need to use a period to indicate missing values (use period in the text for both numeric and character missing values).

1024 242  82 54 4.5         4.769999981 
1029 215 128 34 6.300000191 4.96999979

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 689 views
  • 2 likes
  • 3 in conversation