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!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.