I have a data set that has multiple variable with observations, I want to group the a particular variable observations.
Ex -
SubjID Order ROI VISIT .....
XXX 1 ROI1 baseline
XXX 1 ROI1 Screening
XXZ 2 ROI2 baseline
XXZ 2 ROI2 screening
XZX 3 ROI3 baseline
XZX 3 ROI3 screening
I am wishing to get result like this
SubjID ROI VISIT .....
XXX ROI1 baseline
Screening
XXZ ROI2 baseline
Screening
XZX ROI3 baseline
Screening
You wouldn't usually do this in a data set. You would do this for a printed or displayed report and you can get it either by setting it as a GROUP variable in PROC REPORT or in PROC TABULATE.
If you really want it in a data set, use FIRST and BY group processing to set anything not first to missing.
by subjid order roi;
if not first.roi then call missing(roi);
if not first.subjid then call missing(subjid);
@shanky_44 wrote:
I have a data set that has multiple variable with observations, I want to group the a particular variable observations.
Ex -
SubjID Order ROI VISIT .....
XXX 1 ROI1 baseline
XXX 1 ROI1 Screening
XXZ 2 ROI2 baseline
XXZ 2 ROI2 screening
XZX 3 ROI3 baseline
XZX 3 ROI3 screening
I am wishing to get result like this
SubjID ROI VISIT .....
XXX ROI1 baseline
Screening
XXZ ROI2 baseline
Screening
XZX ROI3 baseline
Screening
@shanky_44 wrote:
I have a data set that has multiple variable with observations, I want to group the a particular variable observations.
Ex -
SubjID Order ROI VISIT .....
XXX 1 ROI1 baseline
XXX 1 ROI1 Screening
XXZ 2 ROI2 baseline
XXZ 2 ROI2 screening
XZX 3 ROI3 baseline
XZX 3 ROI3 screening
I am wishing to get result like this
SubjID ROI VISIT .....
XXX ROI1 baseline
Screening
XXZ ROI2 baseline
Screening
XZX ROI3 baseline
Screening
You wouldn't usually do this in a data set. You would do this for a printed or displayed report and you can get it either by setting it as a GROUP variable in PROC REPORT or in PROC TABULATE.
If you really want it in a data set, use FIRST and BY group processing to set anything not first to missing.
by subjid order roi;
if not first.roi then call missing(roi);
if not first.subjid then call missing(subjid);
@shanky_44 wrote:
I have a data set that has multiple variable with observations, I want to group the a particular variable observations.
Ex -
SubjID Order ROI VISIT .....
XXX 1 ROI1 baseline
XXX 1 ROI1 Screening
XXZ 2 ROI2 baseline
XXZ 2 ROI2 screening
XZX 3 ROI3 baseline
XZX 3 ROI3 screening
I am wishing to get result like this
SubjID ROI VISIT .....
XXX ROI1 baseline
Screening
XXZ ROI2 baseline
Screening
XZX ROI3 baseline
Screening
@shanky_44 wrote:
I have a data set that has multiple variable with observations, I want to group the a particular variable observations.
Ex -
SubjID Order ROI VISIT .....
XXX 1 ROI1 baseline
XXX 1 ROI1 Screening
XXZ 2 ROI2 baseline
XXZ 2 ROI2 screening
XZX 3 ROI3 baseline
XZX 3 ROI3 screening
I am wishing to get result like this
SubjID ROI VISIT .....
XXX ROI1 baseline
Screening
XXZ ROI2 baseline
Screening
XZX ROI3 baseline
Screening
Thanks Reeza,
Thanks that worked, although my problem is more complex but your answer helped me to understand the concept. Appreciate your help!
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.