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

data have;
input (league team captain) ($);
datalines;
N A N1
N B N2
N C N3
S A N4
S B N5
S C N6
;

I would like to use PROC REPORT to generate the following report :

             team
           A   B   C
league
N         N1  N2  N3
S         N4  N5  N6

PG
1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

Hi, the "trick" is that REPORT will not like to use a character value under an ACROSS variable unless you give it something to "summarize". Try out the attached code. #1 will not work because PROC REPORT "wants" a statistic associated with CAPTAIN, but #2 will do what you want. After you see that #2 is working, you can use NOPRINT on the DEFINE statement to hide it on the report.

cynthia

ods html file='c:\temp\makedummyvar.html';

proc report data=have nowd;

  title '1st try';

  column league team,captain;

  define league / group;

  define team / across;

  define captain / display;

run;

proc report data=have nowd;

  title1 '2nd try with dummyvar';

  column league team,captain dummyvar;

  define league / group;

  define team / across;

  define captain / display;

  define dummyvar / computed /* noprint */;

  compute dummyvar;

    dummyvar = 1;

  endcomp;

run;

ods html close;

View solution in original post

2 REPLIES 2
Cynthia_sas
SAS Super FREQ

Hi, the "trick" is that REPORT will not like to use a character value under an ACROSS variable unless you give it something to "summarize". Try out the attached code. #1 will not work because PROC REPORT "wants" a statistic associated with CAPTAIN, but #2 will do what you want. After you see that #2 is working, you can use NOPRINT on the DEFINE statement to hide it on the report.

cynthia

ods html file='c:\temp\makedummyvar.html';

proc report data=have nowd;

  title '1st try';

  column league team,captain;

  define league / group;

  define team / across;

  define captain / display;

run;

proc report data=have nowd;

  title1 '2nd try with dummyvar';

  column league team,captain dummyvar;

  define league / group;

  define team / across;

  define captain / display;

  define dummyvar / computed /* noprint */;

  compute dummyvar;

    dummyvar = 1;

  endcomp;

run;

ods html close;

PGStats
Opal | Level 21

Well I'll be... It works! Thanks Cynthia. That's far from intuitive, at least for me.

PG

PG

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 2 replies
  • 1339 views
  • 0 likes
  • 2 in conversation