BookmarkSubscribeRSS Feed
RajasekharReddy
Fluorite | Level 6

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;

4 REPLIES 4
RW9
Diamond | Level 26 RW9
Diamond | Level 26

data want;

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

     by ...;

     if a and b then output;

run;

RajasekharReddy
Fluorite | Level 6

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;

Loko
Barite | Level 11

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;

husseinmazaar
Quartz | Level 8

data want;

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

     by PATIENT;

     if a and b;

where amt ne ' ';

run;

thanks

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to choose a machine learning algorithm

Use this tutorial as a handy guide to weigh the pros and cons of these commonly used machine learning algorithms.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 1177 views
  • 0 likes
  • 4 in conversation