From: Al on
Dear All:


1.I want to use proc freq for all the variables in each dataset from a
library and output the results.


2.I want to calcualte number of days from randomization for all the
dates present in each dataset from a library

i was able to do it individually but a macro for this would be really
great

Any suggestions


Thanks in advance
Al
From: Arthur Tabachneck on
Al,

Some sample data (in the form of a data step), as well as the code you
wrote that does what you want, would definitely help to understand
what you want to do.

Art
--------------
On Jun 30, 11:19 am, Al <ali6...(a)gmail.com> wrote:
> Dear All:
>
> 1.I want to use proc freq for all the variables in each dataset from a
> library and output the results.
>
> 2.I want to calcualte number of days from randomization for all the
> dates present in each dataset from a library
>
> i was able to do it individually but a macro for this would be really
> great
>
> Any suggestions
>
> Thanks in advance
> Al

From: Lou on

On Jun 30, 11:19 am, Al <ali6...(a)gmail.com> wrote:
> Dear All:
>
> 1.I want to use proc freq for all the variables in each dataset from a
> library and output the results.
>
> 2.I want to calcualte number of days from randomization for all the
> dates present in each dataset from a library
>
> i was able to do it individually but a macro for this would be really
> great
>
> Any suggestions

You don't give us much to go on.

1. Assuming the PROC FREQ is something like

PROC FREQ DATA = yourlibname.somedataset;
QUIT;

you can do something along the lines of:

%MACRO FREQS(somedataset);
PROC FREQ DATA = yourlibname.&somedataset;
QUIT;
%MEND;
PROC SQL NOPRINT;
SELECT "%FREQS(" || TRIM(MEMNAME) || ');' INTO :FREQS
FROM SASHELP.VTABLE
WHERE LIBNAME = 'yourlibname';
QUIT;
&FREQS;
%SYMDEL FREQS;

2. The hard part here is to determine which variables are dates. Your
reference to a randomization date hints at the possibilty you're working
with clinical trial data. If your data library has datasets in SDTM
compliant format, date variable names should end in "DTC". You can use that
fact to get a list of variables and the datasets they're in by doing
something on the order of:

PROC SQL;
CREATE TABLE DATEVARS AS
SELECT MEMNAME, NAME
FROM DICTIONARY.COLUMNS
WHERE LIBNAME = 'yourlibname' AND
NAME LIKE '%DTC';
QUIT;

Once you have your list of variables, it should be relatively
straightforward to go on to comparing their values to some randomization
date.

If your data are not SDTM compliant, the task becomes more problematic. You
could try searching associated formats, or search variable labels. The
WHERE clauses would look something like

WHERE LIBNAME = 'yourlibname' AND
FORMAT IN ('format1', 'format2',...,'formatn');
or
WHERE LIBNAME = 'yourlibname' AND
LOWCASE(LABEL) CONTAINS ' date';

No guarantees that you'd catch every date variable in the absence of some st
andard naming or labelling convention, though.