Skip to content

Instantly share code, notes, and snippets.

@abhishekdagarit
Last active September 27, 2017 15:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abhishekdagarit/03f1f5fb402b574f336739b8197db585 to your computer and use it in GitHub Desktop.
Save abhishekdagarit/03f1f5fb402b574f336739b8197db585 to your computer and use it in GitHub Desktop.
Basic SQL commands to be used in SAS as well as any other place.

SQL select statement

Select

Simplest Select satament

proc sql;
select * 
from sashelp.cars;
quit;

Where

proc sql;
select * 
from sashelp.cars
where make="Honda";
quit;

Group

proc sql;
select *
from sashelp.cars
where make="Honda" 
group by make;
quit;

As - renaming a variable as something else

proc sql;
select sum(price) as Total_Price
from sashelp.cars;
where make="Honda"
quit;

Having

Points to consider

  1. run; doesn't have any effect. You can use quit; instead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment