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
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.