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

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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