Hi,
In proc report i want to display as shown before
Name Address plans
john 6325 holly dr XXX
raliegh,NC YYY
27540 ZZZ
In my data set i have the address field as three variables and the plans in one variable.
Name address 1 address 2 address 3 plans
john 6325 holly dr raliegh,nc 27540 xxx
john 6325 holly dr raliegh,nc 27540 YYY
john 6325 holly dr raliegh,nc 27540 ZZZ
i am doing it as
PROC REPORT DATA=test NOWD MISSING SPLIT='*'
columns Name address 1 address 2 address 3 plans
define name / group
define address / computed
define plans / display
compute address / char length =105
address=address 1||"~{newline}"||address 2 ||"~{newline}"||address 3;
endcomp;
run;
The problem i am having is it is displaying as shown below
Name address plans
john 6325 holly dr XXX
raliegh,NC
27540
YYY
ZZZ
I want to remove the extra space between Plans.Can you please help me regarding that
Hi:
I have a couple of observations and some questions.
Are the variables actually named "address 1", "address 2" and "address 3" with spaces in the variable name, or are your showing the variable label?? Given something similar to your COLUMN statement, I would expect your LOG to show an ERROR message or two:
279 column name address 1 address 2 address 3 address PLANS;
I don't see your DEFINE statements for "ADDRESS 1", "ADDRESS 2" and "ADDRESS 3" -- I do see your DEFINE statement for the computed item ADDRESS. But I don't see how your code is working. I would expect to see ADDRESS1, ADDRESS2, ADDRESS3 as DISPLAY items with NOPRINT specified in the DEFINE statement. Can you show ALL your code, including the ODS statements? And/or, can you post your complete SAS Log?
And, how is this data file being created so that PLANS is a different value on every row, but address values 1, 2, and 3 (however they are named) are all the same on every row? It might actually be easier to pre-process the file with a DATA step program rather than expecting PROC REPORT to deal with the input dataset that you show.
I don't understand how you are getting the results you posted, especially since you didn't post your ODS statements -- what is your destination of interest? {NEWLINE} won't work in the LISTING destination -- so your output must be to some other destination. Your code should not have produced any output with spaces in the variable names and you didn't show the use of "Address 1"n construct.
Also, I don't understand how you are getting output the way you describe with NAME as a GROUP item, but another item (such as PLANS or ADDRESS1, ADDRESS2, ADDRESS3) as DISPLAY item(s). I would expect to see something like this in the LOG:
NOTE: Groups are not created because the usage of plans is DISPLAY. To avoid this note, change
all GROUP variables to ORDER variables.
So...given my incomplete understanding of your data and your actual code, my idea would be to pre-process your DATA with a DATA step program using BY group processing and FIRST.byvar/LAST.byvar logic, so you can easily concatenate the various values for PLANS and then create ADDRESS when you are on the last observation for NAME. Then, after the data is "cleaned up" you can pass the data to PROC REPORT.
You can also open a track with Tech Support, they could look at your actual data and your actual code and determine your destination of interest and help you come to the best solution.
cynthia
-
22
76
ERROR 22-322: Syntax error, expecting one of the following: a name, ;, (, ',', -, :, =, _ALL_,
_CHARACTER_, _CHAR_, _NUMERIC_.
ERROR 76-322: Syntax error, statement will be ignored.
Thanks Cynthia for your reply.It's my bad not to post the whole code.i appreciate your patience and support.
You need to pre- process the dataset firstly.
data temp; infile datalines dlm=' '; input (Name address1 address2 address3 plans) ( & $20.); datalines; john 6325 holly dr raliegh,nc 27540 xxx john 6325 holly dr raliegh,nc 27540 YYY john 6325 holly dr raliegh,nc 27540 ZZZ Patrick 6325 holly dr raliegh,nc 27540 xxx Patrick 6325 holly dr raliegh,nc 27540 YYY Patrick 6325 holly dr raliegh,nc 27540 ZZZ ; run; data want(drop=address: plans); set temp; by name notsorted; length add pla $ 200; retain pla ; add=catx('~n',of address:); pla=catx('~n',pla,plans); if last.name then do; output; call missing(of _all_);end; run; ods listing close; ods html file='c:\x.html' style=sasweb; ods escapechar='~'; proc report data=want nowd; run; ods html close; ods listing;
Ksharp
Hey,
Thanks ksharp it worked for my present scenario .My output destination is PDF.I appreciate your patience and support.
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.