Building models with SAS Enterprise Miner, SAS Factory Miner, SAS Visual Data Mining and Machine Learning or just with programming

Data Step merge

Reply
Contributor
Posts: 30

Data Step merge

hi ,

can any one tell me how we will write below SQL code in data step by using merge

  PROC SQL;

      CREATE TABLE merge AS

      SELECT A.PATIENT,A.DATE , A.PULSE,

      B.PATIENT, B.DOSES, B.AMT  FROM VITALS as A , DOSING as B

      where A.PATIENT=B.PATIENT and B.AMT ne " ";

  quit;

Super User
Super User
Posts: 7,401

Re: Data Step merge

data want;

     merge vitals (in=a) dosing (in=b where=(amt ne ""));

     by ...;

     if a and b then output;

run;

Contributor
Posts: 30

Re: Data Step merge

thanks for providing code for same however small change in code and tell me how we can aply condtion in both data sets as

data want;

     merge vitals (in=a where=(

A.pulse eq 'y') dosing (in=b where=(amt ne ""));

by ...;

     if a and b then output;

run;

 

PROC SQL;

  CREATE TABLE merge AS

  SELECT A.PATIENT,A.DATE , A.PULSE,

  B.PATIENT, B.DOSES, B.AMT  FROM VITALS as A , DOSING as B

  where A.PATIENT=B.PATIENT and A.pulse eq 'Y' and B.AMT ne " ";

  quit;

Super Contributor
Posts: 305

Re: Data Step merge

helo,

/*prepare some data*/

data classwork;
set sashelp.class(where=(sex="M"));
if mod(_N_,2)=0 then call missing(height);
run;

/*output*/
data want;
merge sashelp.class (in=a) classwork (in=b);
by name;
if a and b and height ne .;
run;

Contributor
Posts: 42

Re: Data Step merge

data want;

     merge vitals (in=a) dosing (in=b);

     by PATIENT;

     if a and b;

where amt ne ' ';

run;

thanks

Ask a Question
Discussion stats
  • 4 replies
  • 284 views
  • 0 likes
  • 4 in conversation