Programming the statistical procedures from SAS

How to keep/drop variables using PROC SQL?

Reply
N/A
Posts: 0

How to keep/drop variables using PROC SQL?

I like using PROC SQL since it is the easiest to use. How do I keep/drop variables using PROC SQL?
Super Contributor
Posts: 281

Re: How to keep/drop variables using PROC SQL?

One way to drop variables is actually not to include them in the select statement.

Instead of

SELECT * from ...

you could use

SELECT T.x1,T.x2,T.x27 from ...
N/A
Posts: 0

Re: How to keep/drop variables using PROC SQL?

What if I want to equijoin 3 data sets and the data sets have same variables. I only want to see BILL1-BILL3 variables. How do I use SELECT statement? This is what I have below.

PROQ SQL;
SELECT BILL1 BILL2 BILL3
FROM DS1 DS2 DS3
QUIT;
Valued Guide
Posts: 2,108

Re: How to keep/drop variables using PROC SQL?

Perhaps you need to read more about SQL. Your syntax is missing the comma separators and the WHERE clause. Beyond the manual, Lafler and Prairie have good books in the BBU series.

If all the datasets have the same variables, including bill1-bill3 in each, then an equijoin will probably not get you what you want. The last data set in (ds3) will provide the data values and the data values from ds1 and ds2 will be lost.

If the incoming datasets have a common variable called, say, "bill" and you want to do an equijoin and rename it to bill1, bill2, and bill3 on output, that can be done.

SELECT
ds1.bill AS bill1,
ds2.bill AS bill2,
ds3.bill AS bill3
FROM
ds1, ds2, ds3
WHERE

;
Ask a Question
Discussion stats
  • 3 replies
  • 303 views
  • 0 likes
  • 3 in conversation