Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data in rows to be delimited by semi-colons and in a tring

Status
Not open for further replies.

Queryman

Programmer
Nov 4, 2002
243
US
I have a sas data set that has thouands of records, they are approximately 8 characters long, some less, but not more. I need to know how to concatenate them all together in a string separated by semi-colons.
Thanks,



Michael

 
Try something like this:

data combined;
set separated;
length oneVar $ 10000;
array allvar(*) _character_;
oneVar = allVar(1);
do i = 2 to dim(allvar);
oneVar = trim(oneVar(i)) || ";" || allvar;
end;
run;

I did not test the code. But I think the logic is ok.
 
Do I have to change my variable name to test this, I am not sure I understand the Onevar & allvar
Thanks,



Michael

 
Wait a minute, do you have many fields to be concatenated into one field or one field with many rows to be concatenated into one field in one row?

What I had before is for the first case, oneVar is the concatenated variable name.

For second case, proc transpose would convert it into one row many fields. Then this becomes first case.

If you have second case, but want to output to an external file in one long string, you can try the following:

data_NULL_;
set yourSet;
file 'yourpath/yourFile' dsd delimiter = ";";
put yourfield @;
run;
 
I have the second scenario
Thanks



Michael

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top