I have a list of cities that I want to put into an array from a data set:
data test_array;
set city;
array a(*) city;
do i = 1 to dim(a);
put a(i) = city;
end;
run;
proc print no obs data=test;
run;
code above does not work
I would like the out put to look like this instead of ...
Baltimore Washington Hanover
sorry output to look like this
Baltimore Washington Hanover
instead of this
baltimore
washington
hanover
For the entire dataset?
You can do a proc transpose, but I'm guessing there's some other criteria as well?
Hello Mick_g,
Here is some code to get you started on transforming data from long to wide.
data city (keep = city);
set sashelp.zipcode (firstobs=2000 obs=2010);
run;
data test_array (drop = i city);
array a
do i = 1 to dim(a);
set city;
a(i) = city;
run;
Rich
using @ and / operator.
data _null_; set sashelp.class; put name @; if mod(_n_,3)=0 then put /; run; Alfred Alice Barbara Carol Henry James Jane Janet Jeffrey John Joyce Judy Louise Mary Philip Robert Ronald Thomas
Ksharp
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.
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.