Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
xtracting information from macro variable
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
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
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
hd  
View profile  
 More options Feb 6, 6:19 pm
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.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
cellurl  
View profile  
 More options Feb 7, 9:56 am
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.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
hd  
View profile  
 More options Feb 7, 12:40 pm
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.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Barry Schwarz  
View profile  
 More options Feb 7, 1:26 pm
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

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.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »