how to get the missing row values.

Reply
Contributor
Posts: 40

how to get the missing row values.

hi friends

i have the data set is ds like this.

data ds;

infile datalines missover;

input x$ y;

datalines;

s_count 12

r_count 10

sr_per

p_count 16

q_count 8

pq_per

;

run;

then output dataset is

x    y

s_count 12

r_count 10

sr_per 83.3%

p_count 16

q_count 8

pq_per 50.0%

3 rd row in y column value is (10/12)*100=83.3%

6 th row in y column value is  (8/16)*100=50.0%

plz help me and send the code

Esteemed Advisor
Posts: 5,199

Re: how to get the missing row values.

First: this is a reporting problem, so the solution should prepare the data for stand reporting procedures.  Consider splitting your X column into the grouping values and separate the sequence no. For the reporting part PROC REPORT will probably do the job.

Data never sleeps
Grand Advisor
Posts: 9,593

Re: how to get the missing row values.

Are you sure the lag1 lag2 of Y are always have a value ?

data ds;

infile datalines missover;

input x$ y;

datalines;

s_count 12

r_count 10

sr_per .

p_count 16

q_count 8

pq_per .

;

run;

data want;

set ds;

lag1=lag(y);lag2=lag2(y);

if y=. then y=divide(lag1,lag2);

run;

Xia Keshan

Ask a Question
Discussion stats
  • 2 replies
  • 217 views
  • 3 likes
  • 3 in conversation