format - how could I handle an iterative naming system for this? -


i have dataset of kind, dataset contains missing values (i'm representing them x).

id  va  vb  ... vn      |       id  va  vb  ... vn  |    1   a1  b1  ... n1      |       1   a1  x   ... n1  | 2   a2  b2  ... n2      |===    2   x   b2  ... x   | 3   a3  b3  ... n3      |===    3   a3  b3  ... n3  | ..................      |       ..................  | n    bn  ... nn      |       n   x   bn  ... nn  | 

i want add observations id using 1 variable column, call variable var: inverted proc format id; var var;.

id  var 1   a1 .. 1   n1  2   b2 .. 3   a3 3   b3 .. 3   n3 .. n   bn ..   n   nn 

so tried split olddataset in different datasets (newa newb ...newn) where, in each dataset have not-missing observations stored in column called var. merge newa newb ... newn in newdataset , apply proc sort restoring order id.

the problem arised when realized "n" not known prior analysis 'cause want setup generalized code won't work 1 dataset, , va vb vn result of proc format step.

if n knows use this:

data newa newb newc; set olddataset; array try[3] va vb vc ; if try[1] ne '.' output newa; if try[1] ne '.' output newb; if try[1] ne '.' output newc; run; 

but need iterative naming system maybe sounds like:

data new_i;                     <-------- "i" must assigned set olddataset; array try[*] v: ; i=1 dim(try); if try[i] ne '.' output new_i; <---- "i" must assigned run; 

hope sounds clear. hints? thanks.

try proc transpose instead, can delete missing in second step or add clause out data set. if want create subsets after based on id separate them out in data step.

*generate sample data; data have; array v(20) v1-v20; id=1 10;     i=1 20;     v(i)=rand('normal', 0, 1);     if v(i) < -2 v(i)=.;     end;     output; end; drop i; run;  *flip data; proc transpose data=have out=want(where=(var1 ne .)) prefix=var;     id; run;  *separate different data sets; data _null_;     set want;     id;     call execute(catt("data var", id, "; set want; id=", id, ";run;")); run; 

Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -