hello,
I have a column of data in a dataset which is attached here.
the violation column has TDGA and TDGR. First I need to be able to separate the TDGA from the TDGR and then extract only the number to the left.
For instance, if it is TDGR 6.1, I need only 6 (the digit to the left of the .)
Thanks,
Maitri
First, many of use will not download Excel (or other Microsoft Office) files as they are a security risk. So I can't see your data. The proper way to provide data is: https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/
Next, I don't see any particular need for a macro or macro variable here, you can do this in a DATA step without a macro and without a macro variable, using the SUBSTR function or the ANYDIGIT function. So I suggest you try that (or explain why you think you need a macro or a macro variable).
data _null_;
violation = "TDGR 6.1";
want_var = scan(scan(violation,2," "),1,".");
put want_var=;
run;
No macro needed.
Macros are for dynamic code, which is not the case here.
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.