Hello, I want to require 6 variables (in a wide data format) to be equal to a certain value, pending on a variable's "values". TO make it simple, I created only 2 variables here as an example. Depend on the value in each row of variable "mon", I want to use that value for the suffix "X" of the variable "monthX", and require that "monthX" to be equal "c". Here is my code, and it seem like it only works for the first row. How do I make this work for multiple rows: data a; input id mon $2. month1 $2. month2 $2. ; datalines; 1 2 c c 2 1 c n 3 1 n n 4 2 c n ; run; proc print data=a; run; %macro test(dataset); data _null_; set &dataset. nobs=x; call symputx('max',x); run; data b; set &dataset.; %do i=1 %to &max.; call symputx('mon1',"month"||compress(mon)); if &mon1. in('c') then enroll=1; %end; %mend test; %test(a); proc print data=b; run; And here is the output for the dataset b. The "enroll" variable in row 2, and 4 supposed to be 1 as well. Obs id mon month1 month2 enroll1234 1 2 c c 1 2 1 c n . 3 1 n n . 4 2 c n .
... View more