BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
svh
Lapis Lazuli | Level 10 svh
Lapis Lazuli | Level 10

Hello,

 

The director of my unit has asked me to augment certain metrics with a 1-year and 5-year change (in the form of a percentage). The audience needs to quickly see the change in time. So there is one row per metric in the Excel spreadsheet that I have to create, but the director would like the two percentages placed in one cell in this form:

 

Metric

Current Value

Change

Graduation Rate

81%

1yrΔ+0.4%

5yrΔ+1.6%

 

 

 

 

I have been able to get the Greek delta into the output, but I have not been able to determine how to embed a character that will make the two values into one cell. Here is my code to make the data set, and I'm wondering if someone can point me toward a resource about how you merge (for lack of a better word) two values across two rows into one row when they share a common identifier (in this case, Graduation Rate). 

 

data x;
input year $4. order rate;
Metric='Graduation';
cards;
2007 1 0.750
2010 2 0.800
2011 3 0.815
;
run;

 data y1;
      set x;
	  if year in ('2010' '2011') then do;
             pctchng = dif(rate) / lag(rate) ; 
             period = '1yr'; 
	     output;
	  putlog year= order= rate= pctchng=;
	  end;
	  if year in ('2007' '2011') then do;
	     pctchng = dif(rate) / lag(rate) ; 
period = '5yr';
output; putlog year= order= rate= pctchng=; end; run;
data y1; set y1; if pctchng = . then delete; run;
data y1; set y1; Z= "(*ESC*){unicode delta_U}"; format pctchng percent14.1; text_var = STRIP(PUT(pctchng, percent14.1)); if pctchng > 0 then do; newvar = strip(period)||' '||Z||'+'||(text_var); end; else if pctchng < 0 then do; newvar = strip(period)||' '||Z||'-'||(text_var); end; else if pctchng = 0 then do; newvar = strip(period)||' '||Z||(text_var); end; keep Metric rate newvar; run;
1 ACCEPTED SOLUTION
1 REPLY 1

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
  • 1 reply
  • 252 views
  • 1 like
  • 2 in conversation