i have ran a code:
data us99;
set us13;
annualreportdate=tranwrd(annualreportdate,'Dec','');
run;
for some strange reason, after i get rid of Dec, I get a space between my year ie: (space)2013
how can i remove that space so that the ones that i removed Dec aligns with other year observations?
thank you!
I think there's better ways to do what you want to do...but you need to provide more details.
You can use compress to remove spaces to solve your immediate problem.
In case you would like to remove the character data from the variable, you can try the below code
data have;
annualreportdate='01Dec2013';
annualreportdate=compress(annualreportdate,,'kd');
run;
Thanks,
Jag
annualreportdate=tranwrd(annualreportdate,'Dec','');
for some strange reason, after i get rid of Dec, I get a space between my year ie: (space)2
how can i remove that space
AnnualReportDate = tranwrd( annualreportdate, 'Dec2', '2' ) ;
You might need to repeat it for the 1900s if your reports go that far back (but that seems less likely)
Use another function.
data us99; annualreportdate='Dec2014'; annualreport=prxchange('s/Dec//',-1,annualreportdate); run;
Xia Keshan
To replace to null string, length 0, you need "new" TRANSTRN function and to specify a 0 length string you need a function like TRIMN.
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.
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.