BookmarkSubscribeRSS Feed
deleted_user
Not applicable
My requirement is to generate report Transporter values by Dropzone. I have used below code

Code:

OPTIONS NOCENTER;
data tpdzone;
infile INFL;
input DZONE $ 112-115
TPORT $ 270-273;
*;
PROC SORT nodupkey DATA=tpdzone;
BY DZONE TPORT;
RUN;
*;
*proc print data=tpdzone;
*;
PROC REPORT DATA=tpdzone;
column DZONE TPORT;
define TPORT / 'Transporter' center;
define DZONE / order 'DROP-ZONE' center;


I am getting the output like this:

DROP Tran
-ZON spor
E ter
DZAC 1552
1553
1602
1603
1604
DZAG 1554
1555
1556
1605
1606

Now the requirement is changed to produce the output like this:

DROP Tran
-ZON spor
E ter
DZAC 1552 1553 1602 1603 1604
DZAG 1554 1555 1556 1605 1606 1607


Please help me how I can get the above result. Also please let me how I can suppress message '1THE SAS SYSTEM' messages.


Thanks,
Kris
2 REPLIES 2
Cynthia_sas
SAS Super FREQ
Hi:
Your second question first. You asked: " Also please let me how I can suppress message 'THE SAS SYSTEM' messages."

This is the standard SAS System Title. If you investigate the use of the TITLE statement, you can blank out the default title using the first example or you can reset the title using the second example.
[pre]
** 1) Blank out Title;
title;

** 2) Reset Title to Other String;
title1 'This is My New Title';
[/pre]

Your first question is a bit more difficult to answer. Normally, the reporting procedures, such as PROC PRINT, PROC REPORT and PROC TABULATE operate on your variables in pre-determined manner. Your data seems "long and skinny" I suspect it looks like this when you do a simple PROC PRINT:
[pre]
DZONE TPORT
DZAC 1552
DZAC 1553
DZAC 1602
DZAC 1603
DZAC 1604
DZAG 1554
DZAG 1555
DZAG 1556
DZAG 1605
DZAG 1606
[/pre]

This shows that you have one variable or column called DZONE and another variable or column called TPORT and you have multiple rows or observations. PROC PRINT will show you every single row (with or without OBServation numbers at the far left).

PROC REPORT, as you discovered, adds a little cosmetic flourish by showing only the first DZONE in an ordered group because you have defined a usage of ORDER for the DZONE variable. If you were to leave DZONE as an ORDER variable, but define TPORT as an ACROSS variable, then PROC REPORT would want to COUNT the unique values of TPORT (how many 1552, how many 1553), etc, which is not what you want. PROC TABULATE would want to do the same thing.

Also, you haven't really described what your final result is -- is it a report or an output dataset??? If all you want is a report, then you might need to consider a procedure other than PROC REPORT. I assume that something like this is NOT what you want:
[pre]
Transporter
DROP-ZONE 1552 1553 1554 1555 1556 1602 1603 1604 1605 1606
DZAC 1 1 . . . 1 1 1 . .
DZAG . . 1 1 1 . . . 1 1
[/pre]

But instead you want something more like this. Note that instead of 1 variable called TPORT, there are multiple numbered variables called TPORT1-TPORT5:
[pre]
DZONE tport1 tport2 tport3 tport4 tport5
DZAC 1552 1553 1602 1603 1604
DZAG 1554 1555 1556 1605 1606
[/pre]

The first example above would be created with PROC REPORT; the second example would be created by turning the data from "long and skinny" data into "wide" data by using PROC TRANSPOSE and then using a simple PROC PRINT on the transposed data.

You might want a report that shows just 1 big character variable that was the concatenation of all your unique values for the TPORT variable and this is possible, but it is a more complicated DATA step or SQL program.

Useful information to know would be:
1) what operating system you are using
2) what your ultimate use of the output file/report file is -- you want to print, you are FTPing the file to another platform, or ???
3) what you really want -- a report with TITLES or a dataset without TITLES
---3a) if you want a report -- what are you going to do with the report -- print it, put it into Word, put it on a web site, email to people, open with Excel
---3b) if you want a dataset -- what is the final disposition of the dataset and what is the final structure of the output dataset

If all you need is a report, then the simplest method would be to use the PROC TRANSPOSE/PROC PRINT method. If you need an output dataset in a different structure than the input dataset, then you will have to look to other techniques.

cynthia
Ksharp
Super User
Hi.
In mine sense, Cynthia has the ability to offer you some example code,
but do not know why she not do it.

the following is reference example.
If your data just looks like that.

[pre]
data temp ;
infile datalines dlm=' ' dsd;
input tport $ dzone $;
datalines;
DROP Tran
-ZON spor
E ter
DZAC 1552
1553
1602
1603
1604
DZAG 1554
1555
1556
1605
1606
1607
;run;
data temp;
set temp;
retain _temp;
if not missing(tport) then _temp=tport;
if missing(tport) then tport=_temp;
drop _temp;
run;
data temp;
set temp;
if tport ne lag(tport) then count+1;
run;

data result;
set temp;
by count;
length _dzone $ 100;
retain _dzone ;
if first.count then call missing(_dzone);
_dzone=catx(' ',_dzone,dzone);
if last.count then output;
drop dzone count;
run;
proc print noobs;run;
[/pre]



Ksharp

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 598 views
  • 0 likes
  • 3 in conversation