Agreeing with @Kurt_Bremser . You can't write macros and expect them to work until you have working code without macros.
So, here is your code when run as
%psql(dsname=sashelp.class,x=%str(sex ='F',Age desc))
&DSNAME is replaced by sashelp.class and &X is replaced by %str(sex='F',age desc), producing this incorrect SQL code
proc sql;
select Name ,sex, Age from sashelp.class order by sex='F',Age desc;
quit;
Can you see why this SQL code doesn't work? So first, you have to write correct SQL code without macros and without macro variables, and fix the problems in the code immediately above. Show us correct SQL code that works, without macros and without macro variables, for this situation.
... View more