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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.