Date: Thu, 16 Jun 2005 05:56:35 -0400
Reply-To: Jim Groeneveld <jim1stat@YAHOO.CO.UK>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Jim Groeneveld <jim1stat@YAHOO.CO.UK>
Subject: Re: get the first 5 letters of a macro-var containing comma
Hi Cayburn,
You do not want the first 5, but the first 6 characters. This is the way:
1 %let test=table: test, try, keep;
2 %LET First6 = %SUBSTR(%QUOTE(&test), 1, 6);
3 %PUT First6=&First6.>>>;
First6=table:>>>
Regards - Jim.
--
Y. (Jim) Groeneveld, MSc., Biostatistician, Vitatron b.v., NL
Jim.Groeneveld_AT_Vitatron.com (replace _AT_ by AT sign)
http://www.vitatron.com, http://home.hccnet.nl/jim.groeneveld
My computer always teaches me something new I thought I knew already.
[common disclaimer]
On Thu, 16 Jun 2005 05:10:05 -0400, Cayburn <cayburn@GMX.DE> wrote:
>I have a macro variable which contains comma and i want to get the first 5
>letters of the variable. I tried it with diffenent ways, but i didn't get
>the wished results.
>
>%let test=table: test, try, keep;
>%put &test;
>%PUT %QSUBSTR(%STR(table: test, try, keep),1,6);
>
>%PUT %SUBSTR(%STR(&test),1,6);
>%PUT %QSUBSTR(%STR(&test),1,6);
>%PUT %QSUBSTR(%STR(%SUBSTR("&test",1)),1,6);
>%PUT %SUBSTR(%STR(%SUBSTR("&test",1)),1,6);
>
>I want to get "table:" in this example. I get it, when i use the text
>instead of the macro variable. but i need to get it out from the variable.
>I want to know if the first letters are "table:", "listing:" or "figure".
>Also with the %SCAN-function it doesn't work.
>
>Please could you help me?
|