BookmarkSubscribeRSS Feed
Kyra
Quartz | Level 8

Hi,

 

1. I want to find observations with same MRN's and same visit_id. Then i want to add the MMEdispense for them.

Ultimately want to end up with one row for that observation.

2. I want to find observations with same MRN and different visit visit_id. if proc_start is within one year then delete them and if proc_start

is more than one year then keep them.

 

Thanks.

Part of my SAS dataset is attached.

 

4 REPLIES 4
Kyra
Quartz | Level 8

Data red.opioid;

Input  MRN  VISIT_ID  PROC_START  MMEdispense;

Datalines;

 

1020331                48648679             22APR2014        75.0

1022198                        52165183     17APR2018          225.0

1024630                49793399             19OCT2015         240.0

1024630                49793399             19OCT2015         480.0

1026419                        50195990     10MAR2016        225.0

1029297                48962048             23SEP2014           225.0

1029297                        49174787     08JAN2015          225.0

1029297                        49384901     14APR2015          225.0

1029297                49765729             07OCT2015         300.0

1029297                        50775972     01NOV2016         225.0

;

Run;      

Reeza
Super User

@Kyra Did you run that code? Did it work for you?
I think this works below:

 



Data opioid;
infile cards truncover;
informat mrn $8. visit_ID $8. proc_start date9. mmedispense best12.; 
format proc_start yymmddd10.;
Input  MRN  VISIT_ID  PROC_START  MMEdispense;
Datalines;
1020331 48648679  22APR2014 75.0
1022198 52165183  17APR2018 225.0
1024630 49793399  19OCT2015 240.0
1024630 49793399  19OCT2015 480.0
1026419 50195990  10MAR2016 225.0
1029297 48962048  23SEP2014 225.0
1029297 49174787  08JAN2015 225.0
1029297 49384901  14APR2015 225.0
1029297 49765729  07OCT2015 300.0
1029297 50775972  01NOV2016 225.0
;
Run;    

 

Kyra
Quartz | Level 8

Hi,

 

i imported excel datasheet into SAS. Thus i did not need the data step with datalines.

 

Thanks,
prerna

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 815 views
  • 0 likes
  • 3 in conversation