BookmarkSubscribeRSS Feed
BrahmanandaRao
Lapis Lazuli | Level 10
proc sql;
select * case when sex='F' then  'Female'
else   'Male'  end as newvar from sashelp.class;
quit;
6 REPLIES 6
Amir
PROC Star

Well, the OP has already posted a query...

tarheel13
Rhodochrosite | Level 12

You need to put a comma after the *. 

jimbarbour
Meteorite | Level 14

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

ballardw
Super User

@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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 438 views
  • 0 likes
  • 6 in conversation