@Rakesh93 wrote:
How to assign visitnum when all the Tests are done on same date?
You really should show a brief example of your input data and what you would expect the output to look like.
And if your dates are not SAS Date values then creating such will be the first step.
I am guessing that you want the same visit number for each test on the same day and that the count should start over based on some sort of ID variable(s).
Here may be one way:
data have; input id date :date9. test $; format date date9.; datalines; 1 01Jan2019 A 1 01Jan2019 B 1 01Jan2019 Q 1 01Jan2019 T 1 04Jan2019 Q 1 04Jan2019 T 1 08Jan2019 Z 1 08Jan2019 R ; /* Next step Assumes the data is actually sorted by Id and date */ data want; set have; by id date; retain visitnum; if first.id then visitnum=1; else if first.date then visitnum+1; run;
If it takes more than a single variable to identify an individual then you may need to provide a more detailed example.
Show us a portion of your data.
The computer is only a tool to carry out your wishes.
If you had the data sitting in front of you, and a pencil, what values would you assign? Give an example.
@Rakesh93 wrote:
How to assign visitnum when all the Tests are done on same date?
You really should show a brief example of your input data and what you would expect the output to look like.
And if your dates are not SAS Date values then creating such will be the first step.
I am guessing that you want the same visit number for each test on the same day and that the count should start over based on some sort of ID variable(s).
Here may be one way:
data have; input id date :date9. test $; format date date9.; datalines; 1 01Jan2019 A 1 01Jan2019 B 1 01Jan2019 Q 1 01Jan2019 T 1 04Jan2019 Q 1 04Jan2019 T 1 08Jan2019 Z 1 08Jan2019 R ; /* Next step Assumes the data is actually sorted by Id and date */ data want; set have; by id date; retain visitnum; if first.id then visitnum=1; else if first.date then visitnum+1; run;
If it takes more than a single variable to identify an individual then you may need to provide a more detailed example.
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.
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.