BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sapasupu
Calcite | Level 5

Hello everyone,

I have a data structured as 

sapasupu_0-1587852503609.png

 

I want to convert it into univariate with a new variable as below 

sapasupu_1-1587852607398.png

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.

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

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;
 
 
--
Paige Miller

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

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;
 
 
--
Paige Miller
sapasupu
Calcite | Level 5
Thank you. It worked.

sas-innovate-wordmark-2025-midnight.png

Register Today!

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.


Register now!

How to connect to databases in SAS Viya

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.

Discussion stats
  • 2 replies
  • 900 views
  • 0 likes
  • 2 in conversation