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

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

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!

Register now

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
  • 2600 views
  • 0 likes
  • 3 in conversation