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

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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