You left the BY keyword out. And you don't need to include a constant variable like your new WAY in the BY group. But those are not the issue I think you are asking about.
Basically SAS is saying that just changing the name is not really making a new variable.
So you have two choices. Remove the CALCULATED keyword.
select 'way 3' as way
, id
, t as s_new
, count(*) as freq
from have
group by id, s_new
;
Or add some none destructive operation, like TRIM() for character variables or SUM(var,.) for numeric variables, so that it will treat it as calculated.
select 'way 3' as way
, id
, trim(t) as s_new
, count(*) as freq format=4.
from have
group by id, calculated s_new
;
And if all you wanted was the change the variable name you could just use the RENAME= dataset option on the source dataset.
select 'way 3' as way
, id
, s_new
, count(*) as freq format=4.
from have(rename=(t=s_new))
group by id, s_new
;
... View more