BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Varrelle
Quartz | Level 8

i figured it out!

 

it just required some logic and minor data manipulation.

 

data have;
length report section class1 class2 grp 8 var2 var1 var4 var3 $8;
do report=1;
    do section = 1 to 2;
        if section = 1 then do;
            do class1=0 to 1;
                do class2 = 4 to 1 by -1;
                if class2 = 4 then class3 = " "; else class3=class2;
                    do grp = 1 to 2;

                        if class1 = 0 then do;
                            
                            if class2 = 4 then do;

                                if grp = 1 then do;

                                    var2="k"; var1="1"; var4=" "; var3=" ";output;

                                end;
                                else do;
                                if grp = 2 then do;

                                    var2=" "; var1=" "; var4=" "; var3=" ";output;

                                end;
                                end;

                            end;
                            else do;
                            if class2 = 3 then do;

                                if grp = 1 then do;

                                    var2="k"; var1="z"; var4="z"; var3=" ";output;

                                end;
                                else do;
                                if grp = 2 then do;

                                    var2=" "; var1="y"; var4="y"; var3=" ";output;

                                end;
                                end;

                            end;
                            else do;
                            if class2 = 2 then do;

                                if grp = 1 then do;

                                    var2="k"; var1="z"; var4="z"; var3=" ";output;

                                end;
                                else do;
                                if grp = 2 then do;

                                    var2=" "; var1="y"; var4="y"; var3=" ";output;

                                end;
                                end;

                            end;
                            else do;
                            if class2 = 1 then do;

                                if grp = 1 then do;

                                    var2="k"; var1="z"; var4="z"; var3=" ";output;

                                end;
                                else do;
                                if grp = 2 then do;

                                    var2=" "; var1="y"; var4="y"; var3=" ";output;

                                end;
                                end;

                            end;
                            end;
                            end;
                            end;

                        end;
                        else do;
                        if class1 = 1 then do;

                            if class2 = 4 then do;

                                if grp = 1 then do;

                                    var2="k"; var1="z"; var4=" "; var3=" ";output;

                                end;
                                else do;
                                if grp = 2 then do;

                                    var2=" "; var1="y"; var4=" "; var3=" ";output;

                                end;
                                end;

                            end;
                            else do;
                            if class2 = 3 then do;

                                if grp = 1 then do;

                                    var2="k"; var1="z"; var4="z"; var3="s";output;

                                end;
                                else do;
                                if grp = 2 then do;

                                    var2=" "; var1="y"; var4="y"; var3="r";output;

                                end;
                                end;

                            end;
                            else do;
                            if class2 = 2 then do;

                                if grp = 1 then do;

                                    var2="k"; var1="z"; var4="z"; var3="s";output;

                                end;
                                else do;
                                if grp = 2 then do;

                                    var2=" "; var1="y"; var4="y"; var3="r";output;
                                end;
                                end;

                            end;
                            else do;
                            if class2 = 1 then do;

                                if grp = 1 then do;

                                    var2="k"; var1="z"; var4="z"; var3="s";output;

                                end;
                                else do;
                                if grp = 2 then do;

                                    var2=" "; var1="y"; var4="y"; var3="r";output;

                                end;
                                end;

                            end;
                            end;
                            end;
                            end;


                        end;
                        end;
                        


                    end;
                end;
            end;
        end;
        if section = 2 then do;    
/*            class3 = " ";*/
            do class1=2;
                do class2 = 4 to 1 by -1;
                    if class2 = 4 then class3 = " "; else class3=class2;
                    do grp = 1 to 2;

                        if class1 = 2 then do;

                            if class2 = 4 then do;

                                if grp = 1 then do;

                                    var2=" "; var1="z"; var4=" "; var3=" ";output;

                                end;
                                else do;
                                if grp = 2 then do;

                                    var2=" "; var1="y"; var4=" "; var3=" ";output;

                                end;
                                end;

                            end;
                            else do;
                            if class2 = 3 then do;

                                if grp = 1 then do;

                                    var2=" "; var1="z"; var4=" "; var3=" ";output;

                                end;
                                else do;
                                if grp = 2 then do;

                                    var2=" "; var1="y"; var4=" "; var3=" ";output;

                                end;
                                end;

                            end;
                            else do;
                            if class2 = 2 then do;

                                if grp = 1 then do;

                                    var2=" "; var1="z"; var4=" "; var3=" ";output;

                                end;
                                else do;
                                if grp = 2 then do;

                                    var2=" "; var1="y"; var4=" "; var3=" ";output;

                                end;
                                end;

                            end;
                            else do;
                            if class2 = 1 then do;

                                if grp = 1 then do;

                                    var2=" "; var1="z"; var4=" "; var3=" ";output;

                                end;
                                else do;
                                if grp = 2 then do;

                                    var2=" "; var1="y"; var4=" "; var3=" ";output;

                                end;
                                end;

                            end;
                            end;
                            end;
                            end;


                        end;




                    end;
                end;
            end;
        end;
    end;
end;
run;

proc print data=have;
run;

proc report data=have nowd missing nocompleterows nocompletecols;
title "version 3: plain no formatting";
column report section class1 grp  class2,(var2 var1 var3) class3,(var4)  dummyvar;
define report/group noprint;
define section/group noprint;
define class1/group order=data width=6 nozero;
define grp/group noprint;
define class2/across order=data;
define var2/display width=8;
define var1/display width=8 nozero;
define var3/display width=8 nozero;
define class3/across order=data;
define var4/display width=8 nozero;
define dummyvar/computed noprint;
compute dummyvar;
    dummyvar=1;
endcomp;
run;

SAS Innovate 2025: Call for Content

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!

Submit your idea!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 15 replies
  • 4903 views
  • 1 like
  • 2 in conversation