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 ?

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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