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

What do I need to add in this code to have the HtFt values be organized based on the year? The code I have now just puts the variables in columns, but not in the correct one by year. How do I specify this?

 

data work.Trees;
infile datalines delimiter = ',';
input Type :$6.
Year :4.
HtFt :2.
;
datalines;
Aspen,2009,15
Aspen,2010,16
Maple,2010,6
Maple,2011,8
Maple,2012,10
Spruce,2009,22
Spruce,2010,23
Spruce,2011,24
Spruce,2012,25
;

proc transpose
data = work.Trees
out = work.TreesWide;
by Type;
var HtFt;

run;

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

Add the statement :

 

ID year;

PG

View solution in original post

3 REPLIES 3
PGStats
Opal | Level 21

Add the statement :

 

ID year;

PG
HSM9
Calcite | Level 5

Yes, that was all it needed I guess. Thank you!

Reeza
Super User

The code I have now just puts the variables in columns, but not in the correct one by year.

 

Are you sure about that?

 

You can the ID with PREFIX and/or IDLABEL options but if they're in the wrong place this won't fix that. 

 


@HSM9 wrote:

What do I need to add in this code to have the HtFt values be organized based on the year? The code I have now just puts the variables in columns, but not in the correct one by year. How do I specify this?

 

data work.Trees;
infile datalines delimiter = ',';
input Type :$6.
Year :4.
HtFt :2.
;
datalines;
Aspen,2009,15
Aspen,2010,16
Maple,2010,6
Maple,2011,8
Maple,2012,10
Spruce,2009,22
Spruce,2010,23
Spruce,2011,24
Spruce,2012,25
;

proc transpose
data = work.Trees
out = work.TreesWide;
by Type;
var HtFt;

run;


 

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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