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

I am trying to create a dataset called work.swimlong; from the dataset work.swimminutes. You can see the format for work.swimminutes below in the instream data. I am trying to make work.swimlong in the format that the Mon, Tues, Wed variables are in collected in one variable called "Day", with the appropiate minutes by each day, like this:

Name    Age     Day   Minutes

Ann       26        Mon     51

Ann       26        Tues     19

....

 

data work.swimminutes;
infile datalines delimiter = ',';
input Name :$5.
Age :2.
Mon :2.
Tues :2.
Wed :2.;
datalines;
Ann,26,51,19,22
Bob,30,43,20,60
Chris,41,48,.,36
Dina,21,32,57,22
;

proc transpose
data = work.swimminutes 
out = work.swimlong;

 

Which Var or By statements do I need below to complete the code?

1 ACCEPTED SOLUTION

Accepted Solutions
HB
Barite | Level 11 HB
Barite | Level 11

I think

proc transpose data=swimminutes
	out=swimlog;
	var mon tues wed;
	by name age;
run;

Starts to move you in the right direction.

 

The SAS System      
       
Name Age NAME OF FORMER COL1
VARIABLE
Ann 26 Mon 51
Ann 26 Tues 19
Ann 26 Wed 22
Bob 30 Mon 43
Bob 30 Tues 20
Bob 30 Wed 60
Chris 41 Mon 48
Chris 41 Tues .
Chris 41 Wed 36
Dina 21 Mon 32
Dina 21 Tues 57
Dina 21 Wed 22

 

I don't know how to gracefully rename the columns to Day and Minutes.

View solution in original post

3 REPLIES 3
HB
Barite | Level 11 HB
Barite | Level 11

I think

proc transpose data=swimminutes
	out=swimlog;
	var mon tues wed;
	by name age;
run;

Starts to move you in the right direction.

 

The SAS System      
       
Name Age NAME OF FORMER COL1
VARIABLE
Ann 26 Mon 51
Ann 26 Tues 19
Ann 26 Wed 22
Bob 30 Mon 43
Bob 30 Tues 20
Bob 30 Wed 60
Chris 41 Mon 48
Chris 41 Tues .
Chris 41 Wed 36
Dina 21 Mon 32
Dina 21 Tues 57
Dina 21 Wed 22

 

I don't know how to gracefully rename the columns to Day and Minutes.

marianhabesland
Calcite | Level 5

Thanks! Yeah, I just had to but a rename statement after the OUT = and the columns got renamed

Astounding
PROC Star

That looks right.  To gracefully rename the columns:

 

out=swimlog (rename=(_name_=Day col1=Minutes));

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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