I have a PROC FREQ
code listed below in the frequency output dataset, CNT. I would like to obtain information for the latest collection date in the "Have" dataset. Is there a way to add a step in the PROC FREQ
procedure, or do I need to add an extra data step and merge it with the output CNT data? Please help, thanks.
Proc freq data=Have noprint;
table LabIDs*Test_Code*Match / nopercent nocol out=CNT;
where match in ('N');
run;
You do not provide enough information to answer your own question.
Mainly, what exactly do you mean by "collection date"? Is it a variable in the dataset HAVE? You specify three variables in HAVE (Labids, test_code, match), none of which suggest a collection date.
Is it the creation date of HAVE?
BTW, there is no need for the ** match" expression in the TABLE statement, since you allow only one match value, i.e. where match in ('N').
Please clarify.
@ybz12003 wrote:
I have a
PROC FREQ
code listed below in the frequency output dataset, CNT. I would like to obtain information for the latest collection date in the "Have" dataset. Is there a way to add a step in thePROC FREQ
procedure, or do I need to add an extra data step and merge it with the output CNT data? Please help, thanks.
You ask "for the latest collection date in the "Have" dataset" but your code is getting counts by LabIds and Test_code. So should that request be "for the latest collection date in the "Have" for each LabIds and Test_code combination in the dataset"? Quite a bit different things.
If you want latest date for each combination of LabIds and Test_code AND have a collection date variable one way AND that the sort order for the collection date variable sorts in date order (i.e and an actual SAS date value or a YYYYMMDD value) the following should work.
Proc freq data=Have noprint; table LabIDs*Test_Code*collectiondate*Match / nopercent nocol out=CNT; where match in ('N'); run; data want; set count; by Labids test_code; if last.test_code;l run;
The Collection_Date volume (mmddyy10.) is in the "Have" dataset, but not in the CNT frequency output dataset.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: