Hello All,
(SAS 9.3) I have generated a table of conditional probabilities and I am looking to select from that a specific variable and add it to a different table. Below are two example data sets for what I want to do. I am looking to add CVtypes onto the final dataset based on the probabilities from the probs dataset. An example from below if observation one has a CVtype of T and segment number of 1 then there is a 75% chance observation two is T and 25% chance observations two is C. If T is chosen seg would increase to 2. If C was chosen seg would then be 1.
Randono is included because I though that could be used to pick probabilities (ex if randno is <prob1 then ... else if rand number is >prob1 then...). I think SQL is my best option but I really don't know SQL well enought figure out how to implement it.
Thanks for any help
data probs; infile datalines DSD; input segment cv1 $ cv2 $ terrain $ cvtype $ prob1 prob2; datalines; 1,C,T,roll,C,80,20 2,C,T,roll,C,70,30 3,C,T,roll,C,90,10 4,C,T,level,C,65,35 5,C,T,level,C,0,100 1,T,C,level,T,75,25 2,T,C,roll,T,60,40 3,T,C,roll,T,79,21 4,T,C,roll,T,12,88 5,T,C,roll,T,0,100 ; run; data final; infile datalines DSD; input randno terrain $ cvtype $ seg; datalines; .654654,roll,T,1, .12567,roll,,, .967946,roll,,, .36758,roll,,, .6567654,roll,,, .76314687,roll,,, .65445,level,,, .516874,level,,, .045648,level,,, .989957,level,,, .254658,level,,, ; run;
... View more