when I have variables life Live,Love,Learn - I used : Keep L:;
But When I have Fight,Right and Tight - Is it possible to Use :ight??
If Yes, can you Guide me? I tried :ight - and got the scary brown lines in the log!!
Note : the example is just sample. In reality , I have 100+ variables ending with _SCORE, among 382 Variables!!! :( just want to Keep only the variables ending with _SCORE! :(
What you can do: select the variables you want from SASHELP.VTABLES into macro variables and assemble your keep list from there...
something like:
proc sql; create table vars as select * from sashelp.vcolumn where libname= .... and memname= ... ; quit; %let no=0; data _null_; set vars; where name=:"L"; call symput("no",_n_); call symput("var"!!compress(put(_n_,8.)),name); run;
%macro x; data .... ... keep %do i=1 to &no; &&var&i %end; ; .... run; %mend; %x;
On Thu, 11 May 2006 02:10:41 -0700, Eash <easw...@GMAIL.COM> wrote: >Hi All,
>when I have variables life Live,Love,Learn - I used : Keep L:;
>But When I have Fight,Right and Tight - Is it possible to Use :ight??
>If Yes, can you Guide me? I tried :ight - and got the scary brown lines >in the log!!
>Note : the example is just sample. In reality , I have 100+ variables >ending with _SCORE, among 382 Variables!!! :( just want to Keep only >the variables ending with _SCORE! :(
-----Original Message----- From: SAS(r) Discussion [mailto:SA...@LISTSERV.UGA.EDU] On Behalf Of
Eash Sent: Thursday, May 11, 2006 5:11 AM To: SA...@LISTSERV.UGA.EDU Subject: Keeping Series of variables - tricky Importance: Low
Hi All,
when I have variables life Live,Love,Learn - I used : Keep L:;
But When I have Fight,Right and Tight - Is it possible to Use :ight??
If Yes, can you Guide me? I tried :ight - and got the scary brown lines in the log!!
Note : the example is just sample. In reality , I have 100+ variables ending with _SCORE, among 382 Variables!!! :( just want to Keep only the variables ending with _SCORE! :(
cheerz EasH
______________________________________________________________________ This email transmission and any documents, files or previous email messages attached to it may contain information that is confidential or legally privileged. If you are not the intended recipient or a person responsible for delivering this transmission to the intended recipient, you are hereby notified that you must not read this transmission and that any disclosure, copying, printing, distribution or use of this transmission is strictly prohibited. If you have received this transmission in error, please immediately notify the sender by telephone or return email and delete the original transmission and its attachments without reading or saving in any manner.
On Thu, 11 May 2006 02:10:41 -0700, Eash <easw...@GMAIL.COM> wrote: >Hi All,
>when I have variables life Live,Love,Learn - I used : Keep L:;
>But When I have Fight,Right and Tight - Is it possible to Use :ight??
>If Yes, can you Guide me? I tried :ight - and got the scary brown lines >in the log!!
>Note : the example is just sample. In reality , I have 100+ variables >ending with _SCORE, among 382 Variables!!! :( just want to Keep only >the variables ending with _SCORE! :(
On Thu, 11 May 2006 02:10:41 -0700, Eash <easw...@GMAIL.COM> wrote: >Hi All,
>when I have variables life Live,Love,Learn - I used : Keep L:;
>But When I have Fight,Right and Tight - Is it possible to Use :ight??
>If Yes, can you Guide me? I tried :ight - and got the scary brown lines >in the log!!
>Note : the example is just sample. In reality , I have 100+ variables >ending with _SCORE, among 382 Variables!!! :( just want to Keep only >the variables ending with _SCORE! :(
>cheerz >EasH
EasH,
The LIKE operator and the use of metadata are needed to arrive at your keep list. There are several examples in the archives, but briefly this is how you would go about it.
data test ; retain a_score a1_score b_score score score2 1 ; run ;
proc sql noprint ; select trim(name) into : keeplist separated by " " from dictionary.columns where libname = "WORK" and memname = "TEST" and name like '%_SCORE'; quit ;
You have the right idea but you are working too hard to get the list of variable names.
data work.tricky; retain Fight Right Tight Weight Height 0; stop; run;
%global keepList; proc sql noprint; select name into :keepList separated by ' ' from dictionary.columns where libname='WORK' and memname='TRICKY' and name like '_ight' ; quit; run; %put NOTE: Keeplist = &keeplist;
On 5/11/06, Gerhard Hellriegel <ghellr...@t-online.de> wrote:
> On Thu, 11 May 2006 02:10:41 -0700, Eash <easw...@GMAIL.COM> wrote:
> >Hi All,
> >when I have variables life Live,Love,Learn - I used : Keep L:;
> >But When I have Fight,Right and Tight - Is it possible to Use :ight??
> >If Yes, can you Guide me? I tried :ight - and got the scary brown lines > >in the log!!
> >Note : the example is just sample. In reality , I have 100+ variables > >ending with _SCORE, among 382 Variables!!! :( just want to Keep only > >the variables ending with _SCORE! :(
proc sql noprint ; select name into : KeepList separated by ' ' from dictionary.columns where Libname = 'WORK' and Memname = 'ONE' and upcase(Name) like '%_STUDY' ; quit ;
data one ; set one ( keep = &KeepList ) ; run ;
proc contents data = one ; run ;
Should do it. How you use the macro var Keeplist to keep you wanted vars is up to you I used another data step but I presume one could just as easily use proc datasets.
Toby Dunn
From: Gerhard Hellriegel <ghellr...@T-ONLINE.DE> Reply-To: Gerhard Hellriegel <ghellr...@T-ONLINE.DE> To: SA...@LISTSERV.UGA.EDU Subject: Re: Keeping Series of variables - tricky Date: Thu, 11 May 2006 09:40:29 -0400
What you can do: select the variables you want from SASHELP.VTABLES into macro variables and assemble your keep list from there...
something like:
proc sql; create table vars as select * from sashelp.vcolumn where libname= .... and memname= ... ; quit; %let no=0; data _null_; set vars; where name=:"L"; call symput("no",_n_); call symput("var"!!compress(put(_n_,8.)),name); run;
%macro x; data .... ... keep %do i=1 to &no; &&var&i %end; ; .... run; %mend; %x;
On Thu, 11 May 2006 02:10:41 -0700, Eash <easw...@GMAIL.COM> wrote:
>Hi All, > >when I have variables life Live,Love,Learn - I used : Keep L:; > >But When I have Fight,Right and Tight - Is it possible to Use :ight?? > >If Yes, can you Guide me? I tried :ight - and got the scary brown lines >in the log!! > >Note : the example is just sample. In reality , I have 100+ variables >ending with _SCORE, among 382 Variables!!! :( just want to Keep only >the variables ending with _SCORE! :( > >cheerz >EasH
%global keepList; %let keepList=; proc sql noprint; select name into :keepList separated by ' ' from dictionary.columns where libname='WORK' and memname='TRICKY' and name like '%\_SCORE' escape '\' ; quit; run; %put NOTE: Keeplist = &keeplist;
> when I have variables life Live,Love,Learn - I used : Keep L:;
> But When I have Fight,Right and Tight - Is it possible to Use :ight??
> If Yes, can you Guide me? I tried :ight - and got the scary brown lines > in the log!!
> Note : the example is just sample. In reality , I have 100+ variables > ending with _SCORE, among 382 Variables!!! :( just want to Keep only > the variables ending with _SCORE! :(
On Thu, 11 May 2006 11:01:32 -0400, data _null_; <datan...@GMAIL.COM> wrote: >As you are looking for values that contain one of the LIKE operator's, >operator. You will need to know about the ESCAPE option. See below.
Did not know such an option existed in this context. Learnt something new today.
>%global keepList; >%let keepList=; >proc sql noprint; > select name into :keepList separated by ' ' > from dictionary.columns > where libname='WORK' and memname='TRICKY' > and name like '%\_SCORE' escape '\' > ; > quit; > run; > %put NOTE: Keeplist = &keeplist;
>On 5/11/06, Eash <easw...@gmail.com> wrote: >> Hi All,
>> when I have variables life Live,Love,Learn - I used : Keep L:;
>> But When I have Fight,Right and Tight - Is it possible to Use :ight??
>> If Yes, can you Guide me? I tried :ight - and got the scary brown lines >> in the log!!
>> Note : the example is just sample. In reality , I have 100+ variables >> ending with _SCORE, among 382 Variables!!! :( just want to Keep only >> the variables ending with _SCORE! :(
%LET KeepList = ; %* Create GLOBAL macro variable KeepList;
* Alternative X; proc sql noprint; select trim(name) into : keeplist separated by " " from dictionary.columns where libname = "WORK" and memname = "TEST" and UPCASE(SUBSTR(REVERSE(TRIM(name)),1,6)) EQ 'EROCS_'; quit ;
%PUT Alternative X: KeepList=&KeepList;
%LET KeepList = ; %* you never know......;
* Alternative X+1; proc sql noprint; select trim(name) into : keeplist separated by " " from dictionary.columns where libname = "WORK" and memname = "TEST" and INDEX(name,'_') AND UPCASE(SCAN(name,-1,'_')) EQ 'SCORE'; quit ;
%PUT Alternative X+1: KeepList=&KeepList; =========================================================
The first one (X) obviously generates the note for name Score: NOTE: Invalid argument 3 to function SUBSTR. Missing values may be generated.
Regards - Jim. -- Jim Groeneveld, Netherlands Statistician, SAS consultant home.hccnet.nl/jim.groeneveld
>On Thu, 11 May 2006 02:10:41 -0700, Eash <easw...@GMAIL.COM> wrote:
>>Hi All,
>>when I have variables life Live,Love,Learn - I used : Keep L:;
>>But When I have Fight,Right and Tight - Is it possible to Use :ight??
>>If Yes, can you Guide me? I tried :ight - and got the scary brown lines >>in the log!!
>>Note : the example is just sample. In reality , I have 100+ variables >>ending with _SCORE, among 382 Variables!!! :( just want to Keep only >>the variables ending with _SCORE! :(
proc sql noprint; select name into : keeplist separated by " " from dictionary.columns where libname = "WORK" and memname = "TEST" and prxmatch(prxparse("/_score\b/i"), name); quit;
%put &keeplist.;
On 11 May 2006 02:10:41 -0700, "Eash" <easw...@gmail.com> wrote:
>when I have variables life Live,Love,Learn - I used : Keep L:;
>But When I have Fight,Right and Tight - Is it possible to Use :ight??
>If Yes, can you Guide me? I tried :ight - and got the scary brown lines >in the log!!
>Note : the example is just sample. In reality , I have 100+ variables >ending with _SCORE, among 382 Variables!!! :( just want to Keep only >the variables ending with _SCORE! :(