proc sql;
select * case when sex='F' then 'Female'
else 'Male' end as newvar from sashelp.class;
quit;
And your question is ...
@BrahmanandaRao wrote:
proc sql; select * case when sex='F' then 'Female' else 'Male' end as newvar from sashelp.class; quit;
Well, the OP has already posted a query...
Well, the syntax error is obvious (at least it must be for a poster with 400+ posts here), so it can't be that.
You need to put a comma after the *.
It just needs a comma after the asterisk. Like this:
proc sql;
select *, case when sex='F' then 'Female'
else 'Male' end as newvar from sashelp.class;
quit;
NOTE: PROCEDURE SQL used (Total process time): real time 0:00:00.04 cpu time 0:00:00.03 Timestamp June 25, 2021 10:22:46
@tarheel13 is quite correct in his assessment.
Jim
@BrahmanandaRao wrote:
proc sql; select * case when sex='F' then 'Female' else 'Male' end as newvar from sashelp.class; quit;
You did read the log that clearly points out the error didn't you?
215 proc sql; 216 select * case when sex='F' then 'Female' ---- 22 76 ERROR 22-322: Syntax error, expecting one of the following: ',', FROM, INTO. ERROR 76-322: Syntax error, statement will be ignored. 217 else 'Male' end as newvar from sashelp.class; 218 quit; NOTE: The SAS System stopped processing this step because of errors. NOTE: PROCEDURE SQL used (Total process time): real time 0.00 seconds cpu time 0.00 seconds
The underscores under CASE show where the problem is and the error text says you are missing something like a comma.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.