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;
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.