Hi:
You cannot create &X and then use &X in the same DATA step program as you show in this snippet of code:
[pre]
if com='y' then call symput('x'||left(x),(compress(x||'_Y')));
if com='y' then &x=1;
[/pre]
So, if you create &X with the CALL SYMPUT statement, you must have a step boundary before the use of &X as described in this Tech Support note:
http://support.sas.com/kb/23/182.html
What is not clear to me is what the desired final dataset would look like. Would you have 1 observation with multiple variables??
[pre]
Variable names: _01_Y _02_Y _03_N _04_Y
Variable values: 1 1 1 1
(all on one observation???)
[/pre]
OR, would you have an obs for every obs in your original dataset:
[pre]
New_X New_value (variable names)
_01_Y 1 <--variable values
_02_Y 1 <--variable values
_03_N 1 <--variable values
_04_Y 1 <--variable values
(with 4 observations and the VALUE of X would be recoded to be the new value??)
[/pre]
OR, would you have 8 observations for your original 4 datalines:
[pre]
New_X New_value (variable names)
_01_Y 1 <--variable values based on value of COM
_01_N 0 <--added obs for _01_N = 0
_02_Y 1 <--variable values based on value of COM
_02_N 0 <--added obs for _02_N = 0
_03_N 1 <--variable values based on value of COM
_03_Y 0 <--added obs for _03_Y = 0
_04_Y 1 <--variable values based on value of COM
_04_N 0 <--added obs for _04_N = 0
(with 8 observations -- a Y and N for each value of X.)
[/pre]
cynthia