DATA Step, Macro, Functions and more

PROC SQL - SELECT * - what is the * for?

Accepted Solution Solved
Reply
Occasional Contributor lg2
Occasional Contributor
Posts: 6
Accepted Solution

PROC SQL - SELECT * - what is the * for?

[ Edited ]

i have a code as below.

 

proc sql;

create table sel_me as

  select *

 

 

 

question:why do we use select*


Accepted Solutions
Solution
a month ago
Super Contributor
Super Contributor
Posts: 266

Re: clarification

[ Edited ]

You don't have to.

 

The * is a wildcard.  " select * " means " select everything " and sometimes that is easier than typing everything out. .

View solution in original post


All Replies
Solution
a month ago
Super Contributor
Super Contributor
Posts: 266

Re: clarification

[ Edited ]

You don't have to.

 

The * is a wildcard.  " select * " means " select everything " and sometimes that is easier than typing everything out. .

PROC Star
Posts: 1,591

Re: clarification

[ Edited ]

select * 

from sashelpclass;

quit;

 

is the same as 

specifying all the variables in the select statement

 

basically as short cut 

 

Please run

Proc sql;

select *

from sashelp.class;

quit;

 

and

 

proc sql;

select Name, Sex, Age ,Height ,Weight 

from sashelp.class;

quit;

 

to notice the result

 

 

Super User
Posts: 23,311

Re: PROC SQL - SELECT * - what is the * for?

Mostly because programmers are lazy and if there's a shorter way its much easier. 

Please note that I've rewritten your subject line to be more descriptive. This will help anyone else looking for the same answer in the future. 

 

The SAS SQL documentation is here:

http://documentation.sas.com/?docsetId=sqlproc&docsetTarget=n1e51p1t33ruyyn1iyzqonf3r0cm.htm&docsetV...

 

And has plenty of examples that you can use. Your question would be covered here:

http://documentation.sas.com/?docsetId=sqlproc&docsetTarget=p0hwg3z33gllron184mzdoqwpe3j.htm&docsetV...

 

*

represents all columns in the tables or views that are listed in the FROM clause.

Occasional Contributor
Posts: 17

Re: PROC SQL - SELECT * - what is the * for?

whenever you use * in the select clause of sql, it always means selecting all columns. In the contradictory you can also select particular columns.

Select * from table will select all coulmns

and

select col1,c0l2 from table

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 193 views
  • 2 likes
  • 5 in conversation