I am trying to recode a variable with an IF statement with 3 x AND conditions within it.
When I run the syntax it doesn't present any errors but the variable has not changed.
Example of Syntax:
IF (((Variable_a =0) AND (Variable_b=0)) AND (Variable_c >0)) Variable_d=9999.
I've tried various combinations of ()s but no joy.
All values in each variable are numerical
Any suggestions of how to overcome this?
EDIT - added an 'execute' command to the end of the code. Unfortunately it still doesn't appear to be work.
Related
I am getting an error asking if I am trying to type a formula, but I am not sure what the issue is
=IF(AND(K74="yes",J74">"&S3,J74"<="&S4),$I$74,0)
Condition 1: K74=Yes
Condition 2: J74 between two dates
If true
=I74
PLEASE HELP?!
I tried making it an ifs function but then I dont have enough arguments
I think the issue that there are 3 conditions not two and the solutions I found online focus on two conditions only.
I also tried putting the commas in different places and using semi colons.
You have to build two conditions for the between-check without joing them as text:
=IF(AND(K74="yes",J74>S3,J74<=S4),$I$74,0)
I want to compute multiple new variables for cases that are NOT missing multiple values. For those cases where Var.1 to Var.10 are missing, then I want the computed vars A, B, C to be SYSMIS.
Example code:
DO IF (NOT MISSING(Var.1 to Var.10)).
COMPUTE A=0.
COMPUTE B=0.
COMPUTE C=0.
END IF.
This produces multiple errors:
DO IF - The number of arguments to a function was incorrect.
END IF - The command does not follow an unclosed DO IF command.
I've tried removing periods and adding/removing parentheses to no effect. Thanks for your help.
You could first count the missing values in your multiple set:
count Nmiss=Var.1 to Var.10 (missing).
Now you can use the count in your if statement:
do if Nmiss=0.
...
(or do if Nmiss<10. - depending on your exact goal)
After having worked out a bunch of other errors I'm left with the following
ERROR: P does not have a numeric suffix.
From all the info I've been able to find this happens a lot when using PROC TRANSPOSE, however I'm not using that here (and don't anywhere else in this code).
Data Spillover_HE (rename=(F1=FY F2=BN F3=employeeID F4=grade_subject_ID
F5=AsmtID_agg F6=linkB F7=subgroupID F8=w F9=MGP_SE F10=Residual_SE
F11=Residual_Var F12=mgp_var F13=student_n F14=calcID F15=sumwt F16=MGP
F17=ave_prescore F18=p_imp F19=p_postImp F20=p_sped F21=p_sped_rs
F22=p_sped_se_ss F23=p_sped_st F24=p_sped_tt F25=P-ell F26=p_ed
F27=p_hispanic F28=p_black F29=p_white F30=p_asian F31=p_other
F32=p_blahispmale F33=p_overaundcred F34=p_retained F35=p_transfer
F36=p_top10 F37=p_top5 F38=p_top1 F39=p_bot10 F40=p_bot5 F41=p_bot1
F42=target_population F43=mean_residual_var F44=P_0_5)); run;
Obviously I have a bunch of variables that start with "p". None of them are underlined in the log. I'm using SAS Base, and got the same error in SAS Enterprise Guide.
Not sure what my next move should be. Thanks.
A dash is not a correct character in a variable name.
Replace F25=P-ell into F25=P_ell.
You can use dash to specify a range of variables e.g. rename=(x1-x100=y1-y100). This code renames 100 variables with prefix x to y.
I am writing a SAS program which also uses some macros. However, SAS suddenly stopped running the codes that I submitted. If I select and submit a part of the code, I can see it copied in the log but that's it. No note, error or warning. Neither is the code executed. Doesn't matter if the code is a simple data step without any macro variables.
Am I missing anything? What should I check or verify?
This sounds like a classic case of unbalanced quotes within one of your macros. Running the code below should clear it, then you will need to check the code for the error.
*); */; /*’*/ /*”*/; %mend;
This same problem happened with me during macro coding except it was unmatched parentheses. Original line of problem code was
"...%then %let DLINE=%str(if (P ge 22 and STAFF eq 0 then STAFF=1;);"
Note unmatched "(" character before P variable. Either removing the "("
or adding ")" after "eq 0" solves problem.
I figure out why I also got this issue.
When I collapse all the macro code ( a temporary one just in the same file of my project code), and rerun it.
SAS actually just run the collapsed part, so it is just the first row of the macro.
The code above solves my problem, but I also need to rerun the expanded macro code again to avoid future error.
I have a question concerning Stata. I'm executing a loop in which there might be an error. Whether the error occurs depends on the data at hand. Unfortunately I do not know exactly how the data, which my code is used for, looks like. I only know the variables which are in the data. So I use the command capture to let my do-file run even if an error occurs. But if I use this command, Stata also suppresses the output if the command sometimes works in my loop. Of course, that is not what I want.
My command looks like:
capture list year JCage`x' numberfirmsage`x' AvSizeAge`x'
and is part of a loop. So what can I do in order to solve the problem?
The help for capture tells you that this is done by capture noisily.