BookmarkSubscribeRSS Feed
Karo_22
Calcite | Level 5
I have rearranged my data with simple proc transpose. But my catch is that one of my column headings is month/year combination.

So my data originally looked like this :
WHERE mths1....mths37 is month/year that was calculated via array so for this month mths1 is May2006, mths2= June 2006 etc until mths 37=May 2009. These mths will change every month...so in June 2009 , my mths1 =June2006, mths2=July2006...until mths37=June2009.
So my proc transpose is easy until I got to "rename" my mths1 - mths37"
This ir original data set
company mths1 mths2 mths3 etc
589 5 4 3
590 6 7 8

what I got with with a simple step
proc summary data=dataset;
var mths1-mths37;
by company;
output out=finout (DROP=_TYPE_ _FREQ_) SUM=;
company 589 company 590
mths1 5 6
mths2 4 7
mths3 3 8

What I am looking for is to have a code that will do following

company 589 company 590
May06 5 6
June06 4 7
July06 3 8
etc
May2009 2 3

and next month it would be same as above but it will start left column with June 06 & go down until June 2009.

I am not sure if this is to complicated for forum or I have to create a ticket. But maybe someone could give me some hints, little push to automize that .Thanks a lot.
2 REPLIES 2
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Using a DATA step, setup an ARRAY referencing the range of mnths, and generate a SAS numeric (DATE) variable using the INTNX function and decrement in a DO / END loop using DIM( TO 1 BY -1. Output a new observation with each DO loop pass, thereby creating a vertical representation of your transposed data.

Scott Barry
SBBWorks, Inc.
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Have a look at the SAS support http://support.sas.com/ website and using the SEARCH facility you will find SAS technical papers and also DOC references. Also, here is a Google advanced search argument (limited to the SAS.COM site) that identifies several related matches on the topic of your post:

assigning sas date variables intnx site:sas.com


Here's a few of several technical papers revealed with the Google search:

Sample 24830: Self- adjusting Date Formats
http://support.sas.com/kb/24/830.html


A Beginners Guide to SAS  Date and Time Handling
Wayne Finley, State of California HHSDC, Sacramento, CA
http://www2.sas.com/proceedings/sugi25/25/btu/25p058.pdf

Scott Barry
SBBWorks, Inc.

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
  • 2 replies
  • 573 views
  • 0 likes
  • 2 in conversation