Dear Users,
Below I have a code for transpose the from long to wide the BHAR (1year=252 days, 2year=504 etc)
Is there is a way to do it at the same time for BHR having some kind of macro instead of repeating the procedure again for BHR
data test2;
set test1;
If countdays=252 or countdays=504 or countdays=756;
run;
*move the countdays as columns;
proc transpose data=test2(keep=cusip countdays BHARced)
out=test3
name=BHARced;
id countdays;
by cusip ;
run;
I have also attached the file.
Looking forward for your prompt reply
Many thanks in advance
George
What do you intend to do with the result? If this is some kind of reporting, you are better off with a reporting procedure.
Dear Kurt,
I got a hint from here: https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/p1n2i0ewaj1zian1ria5579z1zjh.htm
I put the proc transpose inside the loop.
Thank you very much for your prompt reply.
Bad things happen when you attempt to name variables starting with numerals and the SAS list code items don't work with them which makes that a poor choice to try to name things as 1Year 2Year etc.
This does basically what you want IF you don't try to start the variable name with a numeral.
proc format ; value d2yr 252='Yr1' 504='Yr2' 756='Yr3' ; proc transpose data=test2(keep=cusip countdays BHARced) out=test3 name=BHARced; id countdays; by cusip ; format countdays d2yr.; run;
But really, you should have a very specific reason for a data structure like that and printing or reporting it is not one.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.