You may have gotten your code to work. But I am pretty sure it does not do what is wanted. You should not have the final "homme=0" statement, because it means that the variable HOMME is always set to 0. And then the exercise of setting to 1 if GENRE=1 is wasted.
I can see that you are pretty new to SAS. You should learn to use the ELSE statement, I think you can get the correct output like this:
data exercice1;
set mydata.exercice1;
if genre=1 then homme=1;
else homme=0;
if genre=2 then femme=1;
else femme=0;
run;
Or, a bit more fast and dirty: a logical expression in SAS evaluates to 1 (true) or 0 (false). So this could also be written as
data exercice1;
set mydata.exercice1;
homme=genre=1;
femme=genre=2;
run;
... View more