BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jenim514
Pyrite | Level 9

Hi!  Want to create a table that counts the total days weteen first and last patient visit (ENCDATE)..variable 'Diff_Enc'  and also a variable that counts total encounters 'Tot_Enc'  (one observation per encounter).

 

data asthma.difference_vist;

set asthma.op_exclusion;

by patssn;

if first.patssn=1 and last.patssn=1 then delete;

Diff_Enc=Encdate-LAG(encdate);

if not (first.patssn=1) then output;

Tot_Enc=encdate+1;

run;

 

The DIFF_ENC gives forrect information, but the Tot_Enc jsut gives '.' in all values.  Can someone please let me know how to properly count the encounters?

 

Thanks!!

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

To get a single obs per patssn, do:

 

data asthma.difference_vist;
Tot_Enc = 0;
do until (last.patssn);
	set asthma.op_exclusion; by patssn;
	if first.patssn then firstEnc = encDate;
	Tot_Enc + 1;
	end;
Diff_Enc = intck("DAY", firstEnc, encDate);
drop firstEnc;
run;

(untested) 

PG

View solution in original post

2 REPLIES 2
kannand
Lapis Lazuli | Level 10

Can you provide some sample data and what you expect in the output? 

 

With what you have provided so far, I would say, use retain statements to save the first and last dates and then calculate the difference before writing to the output. 

 

Good Luck....!!!

Kannan Deivasigamani
PGStats
Opal | Level 21

To get a single obs per patssn, do:

 

data asthma.difference_vist;
Tot_Enc = 0;
do until (last.patssn);
	set asthma.op_exclusion; by patssn;
	if first.patssn then firstEnc = encDate;
	Tot_Enc + 1;
	end;
Diff_Enc = intck("DAY", firstEnc, encDate);
drop firstEnc;
run;

(untested) 

PG

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