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-2024.png

 

Secure your spot at the must-attend AI and analytics event of 2024: SAS Innovate 2024! Get ready for a jam-packed agenda featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events.

 

Register by March 1 to snag the Early Bird rate of just $695! Don't miss out on this exclusive offer. 

 

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