BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I like using PROC SQL since it is the easiest to use. How do I keep/drop variables using PROC SQL?
3 REPLIES 3
Paige
Quartz | Level 8
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 ...
deleted_user
Not applicable
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;
Doc_Duke
Rhodochrosite | Level 12
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

;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 6548 views
  • 0 likes
  • 3 in conversation