Hello everyone,
I have a data structured as
I want to convert it into univariate with a new variable as below
How can I able to achieve that? Tried MV to UV conversion but the Item variable displays only the counts of the Items but not the variable names. Also, PROC TRANSPOSE didn't work. Any clues or help will be appreciated.
Use an array with the VNAME function.
UNTESTED CODE
data want;
set have;
array x onions--eggs;
do i=1 to dim(x);
do j=1 to x(i);
items=vname(x(i));
output;
end;
end;
drop i j onions--eggs;
run;
Use an array with the VNAME function.
UNTESTED CODE
data want;
set have;
array x onions--eggs;
do i=1 to dim(x);
do j=1 to x(i);
items=vname(x(i));
output;
end;
end;
drop i j onions--eggs;
run;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.