Hi I was hoping someone can help me,
I have 1 table with multiple columns, one of the columns is called read_type which is either a 1,2,3 or a 4.
I would like to put all the 1 and 2 in one table and the 3 and 4 in another table. What is the best way to do this?
Do like this
data Table_A Table_B;
set have;
if Read_Type in ('01', '02') then output Table_A;
else output Table_B;
run;
data want1 want2; set have; if read_type in (1,2) output want1; else output want2; run;
This should do the trick.
data want12;
set have;
where read_type<3;
run;
data want34;
set have;
where read_type>2;
run;
In such cases I very much prefer to use a select statement:
data
want1
want2
;
set have;
select (read_type);
when (1,2) output want1;
when (3,4) output want2;
end;
run;
If a value outside the given range 1-4 is encountered, the step will fail, alerting you to the unexpected value.
Hi I was hoping someone can help me, I have a table with many columns, One of the columns is called Read_Type, This column has millions of lines of data which consists of either a 01, 02, 03 or a zero 4. I would like to transfer all the data with a read type of 01 and 02 into Table_A and the remainder into Table_B, what is the best way to do this
Do like this
data Table_A Table_B;
set have;
if Read_Type in ('01', '02') then output Table_A;
else output Table_B;
run;
Why not start by following the guidance on posting a question. Post test data in the form of a datastep:
Show what you want the output to be.
You say in the first post you have 1,2,3,4. In this you say you have 01, 02, 03, 04 or 0, so is that a character variable?
Second, what is wrong with the code examples you have been given so far?
Just replace the values in my when-branches with the correct character values.
@dassuz wrote:
Hi I was hoping someone can help me, I have a table with many columns, One of the columns is called Read_Type, This column has millions of lines of data which consists of either a 01, 02, 03 or a zero 4. I would like to transfer all the data with a read type of 01 and 02 into Table_A and the remainder into Table_B, what is the best way to do this
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.