I want all the DATA VALUES IN ONE VARIABLE (DATA VALUES)

Reply
Contributor
Posts: 34

I want all the DATA VALUES IN ONE VARIABLE (DATA VALUES)

data have;

input EMPName $   ;

cards;

Suresh

Ramesh

naresh

mahesh

;

run;

output::

EMPName

Suresh Ramesh naresh mahesh

in one datavalue.

Super Contributor
Posts: 275

Re: I want all the DATA VALUES IN ONE VARIABLE (DATA VALUES)

data have;

input EMPName $   ;

cards;

Suresh

Ramesh

naresh

mahesh

;

run;

data want(rename=(temp=EMPName));

   set have end=last;

   length temp $100;

   retain temp;

   temp=catx(' ',temp,EMPName);

   if last then output;

   drop EMPName;

   run;

Super User
Posts: 10,500

Re: I want all the DATA VALUES IN ONE VARIABLE (DATA VALUES)

Do you want a dataset? How many are likely to be in your actual data? SAS character variables are limited to 32,767 total characters. If you are planning on putting hundreds of these values into a single variable then you may exceed that limit.

What will you use that value for? There may be other options available.

PROC Star
Posts: 7,363

Re: I want all the DATA VALUES IN ONE VARIABLE (DATA VALUES)

As slchen showed you, it is easy to do. But, I have to ask, why do you want to do that?

Ask a Question
Discussion stats
  • 3 replies
  • 277 views
  • 1 like
  • 4 in conversation