I would like to list variables VAR1 and VAR2 only if FLAG=1.
LIST VAR1 VAR2. ==> will list these variables for all values of
FLAG.
So how can I do this?
thanks
How about these commands?
Recode Flag (1=1) (else=0) into filter_$.
Filter by filter_$.
List Var1 Var2.
Filter off.
You can recode another value to 1.
--
Shu Fai
Hi Shu.
I used your code and I think it's woking fine.
It lists VAR1 and VAR2 only when Flag=1, right?
It is not listing anything and I think it's because all values for
FLAG are different than one.
Thanks for your help.
You can double-check the syntax by changing 1 to another value which
you know exists in the dataset for FLAG, and see whether some cases
are listed. I also nearly always double-check my syntax. I made
mistakes occasionally in the first version. :)
--
Shu Fai
Hi Shu.
Yes, I forced FLAG to be equal to one and all cases are listed now.
Thanks a lot again,
M
If you're only doing one thing with the filter in place, a TEMPORARY
SELECT IF works well with less code, and no need to compute a new
filter variable.
temporary.
select if (FLAG EQ 1).
list var1 var2 .
--
Bruce Weaver
bwe...@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/Home
"When all else fails, RTFM."
thanks Shu, I will try that too.
Thanks for this version.
Marcia, note Bruce's remark ("only doing one thing ..."), which is
important. This version works only for the first command after SELECT
IF that reads data, i.e., the LIST command in this case. In the
version using FILTER, you can include more than one command between
the FILTER BY ... FILTER OFF block, e.g., several LIST commands, or
LIST and DESCRIPTIVE, etc.
Nevertheless, if I am pretty sure all I need is temporary filtering
for one command, I would use Bruce's version too. Simple and clear. I
personally use FILTER more because I may have some other commands to
add later for the filtered group.
--
Shu Fai
DO IF (Condion).
PRINT / varlist . /*PRINT is a transformation */
END IF.
EXE (or another procedure).
Thanks Bruce.
Sorry, I read this quickly and thought it was still Shu responding.
Yes, your suggestion works too.
Thanks again.
I tried this before but with LIST instead of PRINT and it didn't work.
I will try what you suggest too.
Thanks David.