The SAS Output Delivery System and reporting techniques

Splitting string into multiple lines via PROC REPORT

Accepted Solution Solved
Reply
Contributor
Posts: 29
Accepted Solution

Splitting string into multiple lines via PROC REPORT

[ Edited ]

Is there anyway to make the designated SPLIT value apply to strings displayed through the table besides main and column titles? I'm using SAS 9.4.

 

I pre-incorporated in one test but it didn't seem to work. It didn't work either even when I tried concatenating some string variables via COMPUTE block in PROC REPORT. What am I missing?

 

data addy;
  infile datalines dlm='|';
  input name ~$15. address ~$15. city $ state $;
datalines;
Debby Jones|1234 Johnny St|Chicago|IL
Joe Smith|2345 Bobby Dr|New York|NY
Ron Lee|3456 Suzy Ln|Miami|FL
;
run;

data addy_report_feed;
  set addy;
  catty=catx('~',name,address,catx(', ',city,state));
run;

/* test 1 */
proc report data=addy_report_feed split='~';
  column state city name catty;

  define state / display noprint order=internal;
  define city / display noprint order=internal;
  define name / display noprint order=internal;
  define catty / group 'Mailing~Address' flow width=30;

  break after catty / skip;
run;

/* test 2 */
proc report data=addy_report_feed split='~';
  column state city address name addblock;

  define state / display noprint order=internal;
  define city / display noprint order=internal;
  define address / display noprint order=internal;
  define name / display noprint order=internal;
  define addblock / computed 'Mailing~Address' flow width=30;

  compute addblock / char length=40;
	addblock=catx('~',name,address,catx(', ',city,state));
  endcomp;

/*  break after addblock / skip;*/
run;

 


Accepted Solutions
Solution
‎09-06-2017 09:50 PM
Super User
Posts: 10,610

Re: Splitting string into multiple lines via PROC REPORT

[ Edited ]

Use escapechar:

 

 

 

ods escapechar='^';
.................
compute
addblock / char length=40; addblock=catx('^n',name,address,catx(', ',city,state)); endcomp;

 

Fixed a problem

View solution in original post


All Replies
Super User
Posts: 3,764

Re: Splitting string into multiple lines via PROC REPORT

If I understand you correctly you appear to be trying to turn your columns of data into rows just using PROC REPORT.

 

An easier approach might be to transform your data first by creating a general text column that contains name on row 1, address on row 2, city on row 3, state on row 4 and so on. You could use a DATA step or PROC TRANSPOSE for this.

 

Once your data is transformed it makes your PROC REPORT a lot easier.

Solution
‎09-06-2017 09:50 PM
Super User
Posts: 10,610

Re: Splitting string into multiple lines via PROC REPORT

[ Edited ]

Use escapechar:

 

 

 

ods escapechar='^';
.................
compute
addblock / char length=40; addblock=catx('^n',name,address,catx(', ',city,state)); endcomp;

 

Fixed a problem

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 431 views
  • 0 likes
  • 3 in conversation