BookmarkSubscribeRSS Feed
abhityagi
Obsidian | Level 7

Hi Team,

 

I have a sas table and in that table I have 20 columns and all 20 columns have certain values. And here I want to create another sas table from this table where I should two column. in one column I should have all column names of first sas table and in other table I want to store all the values respective to the column names.

 

first dataset:

DATA Abhi;

input a b c d e f g h i j k l m;

datalines;

---

---

--

;

 

outcome dataset result:

1st  2nd 

a       5

a      4

a      3

b     2

b      6

c   8

d   9

e  10

f  11

g  12

h  13

;

 

 

 

thank!

2 REPLIES 2
novinosrin
Tourmaline | Level 20

Take a look at proc transpose and sort.

 

If you could post clear samples,lazy people like me would test the code for you

PGStats
Opal | Level 21

You should get that with :

 

data want;
set abhi;
array _a a--m;
do _i = 1 to dim(_a);
    var = vname(_a{_i});
    value = _a{_i};
    if not missing(value) then output;
    end;
keep var value;
run;

proc sort data=want; by var; run;

(untested)

PG

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 2538 views
  • 0 likes
  • 3 in conversation