5# funwin
These codes should solve your NEW problem. But I think best way is to output file to EXCEL , or other softwares, so you can easily do it.
We mainly need to focus on STATISTICAL ANALYSIS. GOD bless you.
*********************************************************************************
data company;
input company$3. month sales;
datalines;
001 200101 .
001 200102 650
001 200103 .
001 200104 1500
001 200105 850
002 200305 .
002 200306 .
002 200307 .
002 200308 .
002 200309 1600
002 200310 1200
002 200311 .
003 200305 80
003 200306 .
003 200307 190
003 200308 100
run;
proc sort data=company out=companysort;
by company month;
run;
data companynew;
set companysort;
by company month;
retain cfla nmisc;
if missing(sales) then if first.company then do; cfla=1; nmisc=1; end;
else if cfla=1 then nmisc+1;
else do;
if last.company then cfla=1;
else cfla=0;
nmisc=0;
end;
else do; nmisc=0; cfla=0; end;
run;
data companymis(drop =nmisc flag cfla);
set companynew;
retain flag;
if sales=. then if cfla=0 and nmisc=0 then flag=1;
else flag=0;
else if flag=1 then do;
sales=.;
flag=0;
end;
run;
proc print; id company; run;
*** SAS output for data in the code ***;
company month sales
001 200101 .
001 200102 650
001 200103 .
001 200104 .
001 200105 850
002 200305 .
002 200306 .
002 200307 .
002 200308 .
002 200309 1600
002 200310 1200
002 200311 .
003 200305 80
003 200306 .
003 200307 .
003 200308 100
SAS output for data:
data company;
input company$3. month sales;
datalines;
001 200101 700
001 200102 650
001 200103 .
001 200104 1500
001 200105 850
001 200106 .
002 200305 100
002 200306 .
002 200307 .
002 200308 .
002 200309 3600
002 200310 1200
;
run;
results:
company month sales
001 200101 700
001 200102 650
001 200103 .
001 200104 .
001 200105 850
001 200106 .
002 200305 100
002 200306 .
002 200307 .
002 200308 .
002 200309 .
002 200310 1200