BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Tecla1
Quartz | Level 8

Goodmorning,

 

please I remember it's possible to have a PROC SQL with a condition WHERE who put data in two different files as here below:

 

PROC SQL

CREATE TABLE  white black;

a.*

…..

where color eq "white" or "black";

run;

 

Can you confirm and give me the right program format?

Tnks.

 

Tecla

 

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

SQL cannot create more than one table in a single action. You need to run a separate create table for each newly created table.

If you want to create more than one dataset from one existing dataset, SQL is the worst tool, use a data step instead, as you only need one pass through the input.

View solution in original post

7 REPLIES 7
Tecla1
Quartz | Level 8

I have a table wher i put conditions wit where , at last my new table contains only data that replay to conditions and I loose every Others, I need to have a table with data that don't replay to where conditions….

Tnks!!!

 

PeterClemmensen
Tourmaline | Level 20

I think what you want to do is this. 

 

 

proc sql;
    create table white as
        select * from have
        where color eq 'white';
    create table black as
        select * from have
        where color eq 'black';
quit;

 

 

Or with a data step

 

data white black;
    set have;
    if color='white' then output white;
    else if color='black' then output black;
run;
Kurt_Bremser
Super User

SQL cannot create more than one table in a single action. You need to run a separate create table for each newly created table.

If you want to create more than one dataset from one existing dataset, SQL is the worst tool, use a data step instead, as you only need one pass through the input.

Tecla1
Quartz | Level 8

Tnks for your kindly replay !!!

 

gamotte
Rhodochrosite | Level 12
You can mark the thread as solved by accepting one of the answers.

Note that splitting datasets is rarely a good idea as SAS language is specifically designed to facilitate by group processing. What do you want to do that for ?

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 1880 views
  • 2 likes
  • 4 in conversation