Date: Fri, 8 Nov 1996 12:44:34 -0800
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: Bruce Rogers <gxx18300@GGR.CO.UK>
Organization: Medical IR, Glaxo Wellcome
Subject: Re: Simple concatenation problem - Help required
Richard Paterson wrote:
> Hi folks,
> I am perplexed by a what must surely be a simple problem !
> I have a dataset with 10 obs and 1 variable.
> I want to create a macro variable with the value of each observation
> concatenated together and seperated by a space.
> I thought the following code would work -
> data test;
> length all $200;
> retain all;
> set labels end=eof;
> if _n_ = 1 then all=dsid;
> else all=all||dsid;
> if eof then call symput('var1',all);
> But ALL is blank for all obseravations.
> Please can someone put me out of my misery and explain why the above will
> not work !!
The problem is that the variable ALL is padded up to 200 with blank
The concatenate will put the value of DSID after the 200 chars, then
effectively truncate it!
Here's what you need:
all = trim(left(all)) || ' ' || dsis ;