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

Hello

I want to create a data set that will contain 1 row .

The values in this row will be the variables labels.

what is the way to do it please?

 

Data have;
label ID='customer_ID'
       X1='Weight'
	   X2='Height'
	   X3='Education'
	   W='Health';
Input ID X1 X2 X3 W;
cards;
111 10 20 30 40
222 15 30 45 60
777 30 20 20 80
;
run;

Data wanted;
Input ID $ X1 $ X2 $ X3 $ W $;
cards;
cust_ID
Weight
Height
Education
Health
;
Run;
/***The question-How to create wanted data set autmctically***/
1 ACCEPTED SOLUTION

Accepted Solutions
japelin
Rhodochrosite | Level 12
proc contents data=have out=cont(keep=NAME LABEL) noprint;
run;
proc transpose data=cont out=want(drop=_NAME_ _LABEL_);
  var LABEL;
  ID NAME;
run;

View solution in original post

3 REPLIES 3
japelin
Rhodochrosite | Level 12
proc contents data=have out=cont(keep=NAME LABEL) noprint;
run;
proc transpose data=cont out=want(drop=_NAME_ _LABEL_);
  var LABEL;
  ID NAME;
run;
andreas_lds
Jade | Level 19

I am 100% sure that this question has been asked and answered multiple times, so please use the search function.

Are you 100% sure that the values of all labels have values that are valid for variable names?

Ronein
Meteorite | Level 14

I didn't ask to put the labels as variables names.

I asked to put these values as values and use same variables names (and define them as chars)

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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
  • 3 replies
  • 952 views
  • 4 likes
  • 3 in conversation