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

Greetings all,

 

I have the following data set with some missing values. When I try to convert them into 0, however, most of them do not show up. How could I fix this issue?

 

data testing;
infile datalines missover dlm=',';
input id $ visits unitpurchased @;
if unitpurchased=. then unitpurchased=0;
do while (unitpurchased ^=.);
output;
input unitpurchased @;
end;
drop visits;
datalines;
C005,3,15,,39
D2356,4,11,,,5
A323,3,10,15,20
F123,1,
run;

 

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

Since visits contains the number of following columns, do this:

data testing;
infile datalines missover dlm=',' dsd;
input id $ visits @;
do i = 1 to visits;
  input unitpurchased @;
  if unitpurchased = . then unitpurchased = 0;
  output;
end;
drop visits i;
datalines;
C005,3,15,,39
D2356,4,11,,,5
A323,3,10,15,20
F123,1,
run;

 

Edit: added the dsd option.

View solution in original post

3 REPLIES 3
Jagadishkatam
Amethyst | Level 16

Before executing the code use

 

options missing=0;
Thanks,
Jag
Jagadishkatam
Amethyst | Level 16
options missing=0;
data testing;
infile datalines missover dlm=',';
input id $ visits unitpurchased @;
datalines;
C005,3,15,,39
D2356,4,11,,,5
A323,3,10,15,20
F123,1,
run;
Thanks,
Jag
Kurt_Bremser
Super User

Since visits contains the number of following columns, do this:

data testing;
infile datalines missover dlm=',' dsd;
input id $ visits @;
do i = 1 to visits;
  input unitpurchased @;
  if unitpurchased = . then unitpurchased = 0;
  output;
end;
drop visits i;
datalines;
C005,3,15,,39
D2356,4,11,,,5
A323,3,10,15,20
F123,1,
run;

 

Edit: added the dsd option.

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

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!

Register now

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
  • 1590 views
  • 2 likes
  • 3 in conversation