BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi: How to imitate the below data steps using proc sql:

data two;
set one (keep = subjid trt)
output;
trt = 99 /*** assuming trt values in one are 1 and 2 ***/
output;
run;

Thanks.
3 REPLIES 3
CurtisMack
Fluorite | Level 6
I don't think your psuedo code does what you think it does so I ran it to show the real results. Here it is with the SQL equivalent.

data one;
subjid = "Sub1";
trt = 1; output;
trt = 2; output;
subjid = "Sub2";
trt = 1; output;
trt = 2; output;
run;

data two;
set one (keep = subjid trt);
output;
trt = 99;
output;
run;

proc sql;
create table tow2 as
select subjid, trt
from one
union all
select subjid,99 as trt
from one;
quit;
CurtisMack
Fluorite | Level 6
This seems more likely to be what you were trying to do.


data two;
set one (keep = subjid trt);
by subjid;
output;
if last.subjid then do;
trt = 99;
output;
end;
run;

proc sql;
create table tow2 as
select subjid, trt
from one
union all
select subjid,99 as trt
from (select distinct subjid from one);
quit;
deleted_user
Not applicable
Thanks Curtis. Dataset 'One' is already unique [one row per subjid]. Sorry, I left this info out. But you got it anyway 😉

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 Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 3 replies
  • 657 views
  • 0 likes
  • 2 in conversation