BookmarkSubscribeRSS Feed
jerry898969
Pyrite | Level 9
I need to create a data set from scratch.

I need to create some year columns that goes from 1999-2003 then skips a year till 2007.


My data set should look like this
y1999 y2000 y 2001 y2002 y2003 y2005 y2007

Is this possible?

I'm not sure if this is the correct path to take but I have a table that has a variable that has all the years for a product. Some products have some of the years and some have all. I'm trying to find the best way to display that data in a matrix.

Thank you for your help
3 REPLIES 3
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Look at PROC TRANSPOSE to convert a "vertical" observation oriented SAS file to a "horizontal" column oriented SAS file.

Scott Barry
SBBWorks, Inc.

Suggested Google advanced search argument, this topic / post:

proc transpose site:sas.com
Peter_C
Rhodochrosite | Level 12
creating the columns needs no loop, just a simple statement like:[pre] length y1999 -y2003 y2005 y2007 ;[/pre]defines the columns but does not dynamically construct or fill the columns based on the data. For that, use Scott's method - proc transpose

good luck
peterC
jerry898969
Pyrite | Level 9
Thank you both so much for all your help.

The length statement did what I wanted. Thanks

The proc tranpose actually corrected a different issue I was having.


Thanks again for the quick and awesome help.

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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