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

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!

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
  • 984 views
  • 0 likes
  • 4 in conversation