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.