BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Deepak13
Obsidian | Level 7
proc sql;
create table cars
as select * from SASHELP.cars;
quit;


PG 1:
proc sql;
create table cars
as select * from SASHELP.cars;
quit;

log: 
 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 72         
 73         proc sql;
 74         create table cars2
 75         as select * from SASHELP.cars
 76         where type in ("sports");
 NOTE: Table WORK.CARS2 created, with 0 rows and 15 columns.
 
 77         quit;
 NOTE: PROCEDURE SQL used (Total process time):
       real time           0.00 seconds
       cpu time            0.00 seconds
       
 
 78         
 79         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 92         

PG 2:
proc sql;
create table cars6
as select * from sashelp.cars
where model like 'T%';
quit;

Log:
 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 72         
 73         proc sql;
 74         create table cars6
 75         as select * from sashelp.cars
 76         where model like 'T%';
 NOTE: Table WORK.CARS6 created, with 0 rows and 15 columns.
 
 77         quit;
 NOTE: PROCEDURE SQL used (Total process time):
       real time           0.00 seconds
       cpu time            0.02 seconds
       
 
 78         
 79         
 80         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 93         

PG 3:
proc sql;
create table cars7
as select * from sashelp.cars
where make like '%A';
quit;

LOG:
 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 72         
 73         proc sql;
 74         create table cars7
 75         as select * from sashelp.cars
 76         where make like '%A';
 NOTE: Table WORK.CARS7 created, with 0 rows and 15 columns.
 
 77         quit;
 NOTE: PROCEDURE SQL used (Total process time):
       real time           0.00 seconds
       cpu time            0.01 seconds
       
 
 78         
 79         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 92         

Hi,

 

When I tried to create table from a external file using "where" and "Like" statements, the program tipped no glitch but no results were generated, In simple words no error shown in log but no results were created.

 

Kindly make use of the highlighted program and attached source file.

 

NOTE: I use university edition

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

 

where type in ("sports");

 

Text comparisons are case sensitive. Fix the case to match the data and this should work. 

 

You have similar issues with the rest of your queries, cars6 does not have any models that start with T.

 

 71                  proc sql;
 72                 create table cars2
 73                 as select * from SASHELP.cars
 74                 where type in ("Sports");
 NOTE: Table WORK.CARS2 created, with 49 rows and 15 columns.
 
 75                 create table cars6 as select * from sashelp.cars where model like 'T%';
 NOTE: Table WORK.CARS6 created, with 0 rows and 15 columns.

 

 

EDIT: It appears the Model has a leading space in the field in the SASHELP table. 

 

So the second character is actually T. If you add a space it works correctly as expected. 

 


@Deepak13 wrote:
proc sql;
create table cars
as select * from SASHELP.cars;
quit;


PG 1:
proc sql;
create table cars
as select * from SASHELP.cars;
quit;

log: 
 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 72         
 73         proc sql;
 74         create table cars2
 75         as select * from SASHELP.cars
 76         where type in ("sports");
 NOTE: Table WORK.CARS2 created, with 0 rows and 15 columns.
 
 77         quit;
 NOTE: PROCEDURE SQL used (Total process time):
       real time           0.00 seconds
       cpu time            0.00 seconds
       
 
 78         
 79         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 92         

PG 2:
proc sql;
create table cars6
as select * from sashelp.cars
where model like 'T%';
quit;

Log:
 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 72         
 73         proc sql;
 74         create table cars6
 75         as select * from sashelp.cars
 76         where model like 'T%';
 NOTE: Table WORK.CARS6 created, with 0 rows and 15 columns.
 
 77         quit;
 NOTE: PROCEDURE SQL used (Total process time):
       real time           0.00 seconds
       cpu time            0.02 seconds
       
 
 78         
 79         
 80         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 93         

PG 3:
proc sql;
create table cars7
as select * from sashelp.cars
where make like '%A';
quit;

LOG:
 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 72         
 73         proc sql;
 74         create table cars7
 75         as select * from sashelp.cars
 76         where make like '%A';
 NOTE: Table WORK.CARS7 created, with 0 rows and 15 columns.
 
 77         quit;
 NOTE: PROCEDURE SQL used (Total process time):
       real time           0.00 seconds
       cpu time            0.01 seconds
       
 
 78         
 79         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 92         

Hi,

 

When I tried to create table from a external file using "where" and "Like" statements, the program tipped no glitch but no results were generated, In simple words no error shown in log but no results were created.

 

Kindly make use of the highlighted program and attached source file.

 

NOTE: I use university edition

 



 

View solution in original post

2 REPLIES 2
Reeza
Super User

 

where type in ("sports");

 

Text comparisons are case sensitive. Fix the case to match the data and this should work. 

 

You have similar issues with the rest of your queries, cars6 does not have any models that start with T.

 

 71                  proc sql;
 72                 create table cars2
 73                 as select * from SASHELP.cars
 74                 where type in ("Sports");
 NOTE: Table WORK.CARS2 created, with 49 rows and 15 columns.
 
 75                 create table cars6 as select * from sashelp.cars where model like 'T%';
 NOTE: Table WORK.CARS6 created, with 0 rows and 15 columns.

 

 

EDIT: It appears the Model has a leading space in the field in the SASHELP table. 

 

So the second character is actually T. If you add a space it works correctly as expected. 

 


@Deepak13 wrote:
proc sql;
create table cars
as select * from SASHELP.cars;
quit;


PG 1:
proc sql;
create table cars
as select * from SASHELP.cars;
quit;

log: 
 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 72         
 73         proc sql;
 74         create table cars2
 75         as select * from SASHELP.cars
 76         where type in ("sports");
 NOTE: Table WORK.CARS2 created, with 0 rows and 15 columns.
 
 77         quit;
 NOTE: PROCEDURE SQL used (Total process time):
       real time           0.00 seconds
       cpu time            0.00 seconds
       
 
 78         
 79         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 92         

PG 2:
proc sql;
create table cars6
as select * from sashelp.cars
where model like 'T%';
quit;

Log:
 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 72         
 73         proc sql;
 74         create table cars6
 75         as select * from sashelp.cars
 76         where model like 'T%';
 NOTE: Table WORK.CARS6 created, with 0 rows and 15 columns.
 
 77         quit;
 NOTE: PROCEDURE SQL used (Total process time):
       real time           0.00 seconds
       cpu time            0.02 seconds
       
 
 78         
 79         
 80         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 93         

PG 3:
proc sql;
create table cars7
as select * from sashelp.cars
where make like '%A';
quit;

LOG:
 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 72         
 73         proc sql;
 74         create table cars7
 75         as select * from sashelp.cars
 76         where make like '%A';
 NOTE: Table WORK.CARS7 created, with 0 rows and 15 columns.
 
 77         quit;
 NOTE: PROCEDURE SQL used (Total process time):
       real time           0.00 seconds
       cpu time            0.01 seconds
       
 
 78         
 79         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 92         

Hi,

 

When I tried to create table from a external file using "where" and "Like" statements, the program tipped no glitch but no results were generated, In simple words no error shown in log but no results were created.

 

Kindly make use of the highlighted program and attached source file.

 

NOTE: I use university edition

 



 

Deepak13
Obsidian | Level 7
Many thanks for your constant support Reeza!

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 593 views
  • 2 likes
  • 2 in conversation