xtracting information from macro variable
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 |
Newsgroups: comp.soft-sys.sas
From: hd <heen...@gmail.com>
Date: Mon, 6 Feb 2012 15:19:08 -0800 (PST)
Local: Mon, Feb 6 2012 6:19 pm
Subject: xtracting information from macro variable
Hi,
I have a macro variable as below
%let type = 'winsor0595';
I want to extract the following information into three macro variables
%let allletters = 'winsor'
%let upper = 95;
%let lower = 05;
The last 2 are numbers.
Is there a simple way to do this
I have tried
%let strat = %str(compress(&type, '0123456789'));
%let number = compress(&type,
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz');
%let lower =input(substr(&number,1,2),best4.);
%let upper = input(substr(&number,3,2),best4.);
This does not work.
Any help is appreciated!
Thank you!
You must Sign in before you can post messages.
You do not have the permission required to post.
|
 |
Newsgroups: comp.soft-sys.sas
From: cellurl <gpscru...@gmail.com>
Date: Tue, 7 Feb 2012 06:56:06 -0800 (PST)
Local: Tues, Feb 7 2012 9:56 am
Subject: Re: xtracting information from macro variable
You might try things like this which work for me.
data base;
set base;
order = input(thing,myorder.);
if thing eq 'a' then thingb=substr(thing,2,2);
You must Sign in before you can post messages.
You do not have the permission required to post.
|
 |
Newsgroups: comp.soft-sys.sas
From: hd <heen...@gmail.com>
Date: Tue, 7 Feb 2012 09:40:12 -0800 (PST)
Local: Tues, Feb 7 2012 12:40 pm
Subject: Re: xtracting information from macro variable
On Feb 7, 9:56 am, cellurl <gpscru ...@gmail.com> wrote:
> You might try things like this which work for me.
> data base;
> set base;
> order = input(thing,myorder.);
> if thing eq 'a' then thingb=substr(thing,2,2);
thanks for your help not sure what thing is though..
You must Sign in before you can post messages.
You do not have the permission required to post.
|
 |
Newsgroups: comp.soft-sys.sas
From: Barry Schwarz <schwa...@dqel.com>
Date: Tue, 07 Feb 2012 10:26:47 -0800
Local: Tues, Feb 7 2012 1:26 pm
Subject: Re: xtracting information from macro variable
On Mon, 6 Feb 2012 15:19:08 -0800 (PST), hd <heen ...@gmail.com> wrote:
>Hi,
>I have a macro variable as below
>%let type = 'winsor0595';
>I want to extract the following information into three macro variables
>%let allletters = 'winsor'
>%let upper = 95;
>%let lower = 05;
>The last 2 are numbers.
>Is there a simple way to do this
>I have tried
>%let strat = %str(compress(&type, '0123456789'));
>%let number = compress(&type,
>'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz');
>%let lower =input(substr(&number,1,2),best4.);
>%let upper = input(substr(&number,3,2),best4.);
>This does not work.
First decide if you are writing macro code or data step code. Then
remember that all macro variables are strings.
%let allletters = %substr(&type,1,6);
%let lower = %substr(&type,7,2);
%let upper = %substr(&type,9,2);
If you need to search for the first digit
%do i = 1 %to %length(&type);
%if %datatyp(%substr(&type,&i,1) = 'NUMERIC' then
%goto found;
%end;
/* optional error handling */
%found:
%let allletters = %substr(&type,1,%eval(&i-1));
%let lower = %substr(&type,&i,2);
%let upper = %substr(&type,%eval(&i+2),2);
-- Remove del for email
You must Sign in before you can post messages.
You do not have the permission required to post.
|
|
|