Write and run SAS programs in your web browser

problem using select when

Reply
Contributor
Posts: 31

problem using select when

Can you check upon this.

 


libname l '/folders/myfolders';
data carselect;
set l.permanent;

select(Manufacturer);
LENGTH country $200;
when("Honda","Lexus","Mitsubis","Infiniti") country = "Japan";
when("Hyundai") country=""SouthKorea";
when("BMW","Audi"," Mercedes") country = "germany";
when("Jaguar") country = "India";

when("Acura","Buick","Cadillac","Chevrole","Chrysler","Dodge","Ford","Jeep","Lincoln") country = "USA";

 

otherwise country = "other";
end;

run;

 

 

 

log

1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
55
56 libname l '/folders/myfolders';
NOTE: Libref L was successfully assigned as follows:
Engine: V9
Physical Name: /folders/myfolders
57 data carselect;
58 set l.permanent;
59
60 select(Manufacturer);
61 LENGTH country $200;
62 when("Honda","Lexus","Mitsubis","Infiniti") country = "Japan";
63 when("Hyundai") country=""SouthKorea";
__
49
__________
388
76
64 when("BMW","Audi","Mercedes") country = "germany";
___ ______________ ________
49 49 49
65 when("Jaguar") country = "India";
______________ ________
49 49
NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release. Inserting white space
between a quoted string and the succeeding identifier is recommended.
 
ERROR 388-185: Expecting an arithmetic operator.
 
ERROR 76-322: Syntax error, statement will be ignored.
 
66
67 when("Acura","Buick","Cadillac","Chevrole","Chrysler","Dodge","Ford","Jeep","Lincoln") country = "USA";
___ ___ ___ ___ ___ ___ ______________
_______________________
49 49 49 49 49 49 49 49
NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release. Inserting white space
between a quoted string and the succeeding identifier is recommended.
 
68
69
70
71 otherwise country = "other";
72 end;
73
74 run;
75
76
77 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
78 ODS HTML CLOSE;
79 &GRAPHTERM; ;*';*";*/;RUN;
 
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.CARSELECT may be incomplete. When this step was stopped there were 0 observations and 16 variables.
WARNING: Data set WORK.CARSELECT was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.06 seconds
cpu time 0.07 seconds
 
79 ! QUIT;
 
80 QUIT;RUN;
81 ODS HTML5 (ID=WEB) CLOSE;
82
83 ODS RTF (ID=WEB) CLOSE;
84 ODS PDF (ID=WEB) CLOSE;
NOTE: ODS PDF(WEB) printed no output.
(This sometimes results from failing to place a RUN statement before the ODS PDF(WEB) CLOSE statement.)
85 FILENAME _GSFNAME;
NOTE: Fileref _GSFNAME has been deassigned.
86 DATA _NULL_;
87 RUN;
 
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
 
 
88 OPTIONS NOTES STIMER SOURCE SYNTAXCHECK;
89
Super Contributor
Posts: 490

Re: problem using select when


rishabhmehra13 wrote:

....
when("Hyundai") country=""SouthKorea";

....

 

 
Super User
Posts: 5,367

Re: problem using select when

Yes, removing the extra quote will solve one of the problems.  But your syntax for SELECT statements is not valid.  Here is an abbreviated version of what you will need to change:

 

length country $200;

select;
when(Manufacturer in ("Honda","Lexus","Mitsubis","Infiniti")) country = "Japan";
when(Manufacturer in ("Hyundai")) country=""SouthKorea";
when(Manufacturer in ("BMW","Audi"," Mercedes")) country = "germany";

...

otherwise country = "other";
end;

Ask a Question
Discussion stats
  • 2 replies
  • 214 views
  • 0 likes
  • 3 in conversation