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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.
Ready to level-up your skills? Choose your own adventure.