Hello everyone
I wish to write a code, so it is possible to read the last couple of years performance in a table, so I want to pick the last date in the previous years.
My code is as follows:
PROC REPORT DATA = Performance_3_Aar HEADLINE NOWINDOWS SPLIT='*' Contents='' /* Removes node entirely */ spanrows /* Θn stor celle pr. gruppe vμrdi */
%ReportStyles
STYLE(column) = [background=white cellwidth=75pt]
STYLE(report)= [font_size=0.8 font_face=Times]; /* Makro med report indstillinger */
TITLE FONT=Times HEIGHT=4 Color=Black "Afkast, performance og markedsvμrdi (pct. og mio. kr.) pσ forvaltere pr. %SYSFUNC(putn(&ReportDate,DDMMYY10.))";
FOOTNOTE FONT=Times HEIGHT=4 Color=Black 'Performance mσlt ift. forvalter benchmark.';
WHERE ToDate = &ReportDate AND mv >= 0.5 AND (ParentNodeName NE 'Aktier' AND ParentNodeName NE 'Obligationer' AND ParentNodeName NE 'Ejendomme');
COLUMNS OBS ParentNodeName ModelPortfolioName Performance Performance_2010 Performance_2011 Performance_2012;
DEFINE OBS / GROUP NOPRINT;
DEFINE ParentNodeName / 'Type' GROUP;
DEFINE ModelPortfolioName / 'Forvalter' GROUP STYLE(column) = [cellwidth=/*150pt*/130pt] ORDER=DATA;;
DEFINE Performance / 'Perfor- * mance ÅTD' FORMAT=COMMAX20.1 STYLE(column) = [cellwidth=/*50pt*/40pt] style(column) = {font_weight=Bold foreground=cback.};
DEFINE Performance_2010 / 'Performance 2010' FORMAT=COMMAX20.1 STYLE(column) = [cellwidth=/*50pt*/40pt] style(column) = {font_weight=Bold foreground=cback.};
DEFINE Performance_2011 / 'Performance 2011' FORMAT=COMMAX20.1 STYLE(column) = [cellwidth=/*50pt*/40pt] style(column) = {font_weight=Bold foreground=cback.};
DEFINE Performance_2012 / 'Performance 2012' FORMAT=COMMAX20.1 STYLE(column) = [cellwidth=/*50pt*/40pt] style(column) = {font_weight=Bold foreground=cback.};
BREAK BEFORE ParentNodeName / SUPPRESS OL SKIP UL OL STYLE(SUMMARY)= {FONT_WEIGHT=BOLD BACKGROUND=LIGHTGREEN font_size=1};
RUN;
For the variables Performance_2010, Performance_2011 and Performance_2012 i need to write a statement, so that Sas will read the performance at the date 31/12/2010 in Column A, the date 31/12/2011 in column B and the date 31/12/2012 in column C in the dataset.
I am not sure how I should write this statement.
Can someone help me?
I would really appreciate it
Thanks
Can you explain some more how your original data is structured? I don't quite follow what you want.
Hello
My dataset is basically structured with a date variable called todate. And other that some variables with the performances from differtent years in different columns.
And i want to pick the date 31/12 in these columns.
So i want to write a statement such as:
Where todate=reportdate in column performance (this is the column for performance for 2013) and todate =mdy(12, 31, 2010) in colmun performance_2010 and todate = mdy(31, 12, 2011) in column performance_2011.
And so on for the other years.
But i am not sure how to write this statement in sas.
Hi Bruce123
One step to approach this is to use Proc TRANSPOSE to restructure your data, and then use some macro logic to build the Proc REPORT code, see sample below.
Hello
Thanks for your help.
I will try this as soon as possible
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.