I am using a do loop in array and new variables being created based on some if/then conditions;
If i did not reset the new variables to missing then there is a chance that their values are carried forward from previous if any of the future ones have a missing value???
is this only in the Do loops??
Thanks
Any datastep with multiple Output statements will output the values of any variables at the time of execution. Do loops coupled with arrays are basically just a shorthand form of doing the same calculations multiple times.
For example;
varx = vary +3;
output;
varx = varz -2;
output;
creates two records with different values of varx but any other variables have the values at the time of the Output statement execution.
You only have to worry about the "carrying forward" of the missing values within the current execution of The Do loop. Fi a new value is NOT assigned for a variable then yes it will have the same value as the previous pass through the loop.
All the values are reset with values for the next record from Set or Input statements. (Warning: Retain statement is designed to work around this behavior. OR if you have multiple Set or Input statements things could get very confusing quickly.)
In one of your other posts I recommended a way to output a bunch of new variables corresponding to each variable in your arrays so that a corresponding outcome was directly tied to the input instead of a simple flag that basically said "one of the conditions was met somewhere in the comparisons". I believe that approach lends itself in general to better analysis in many cases because then it has which and how many of the comparisons were met/failed instead of trying to create very complicated logic straight.
Please give an example. Too much missing dots.
Haikuo
Any datastep with multiple Output statements will output the values of any variables at the time of execution. Do loops coupled with arrays are basically just a shorthand form of doing the same calculations multiple times.
For example;
varx = vary +3;
output;
varx = varz -2;
output;
creates two records with different values of varx but any other variables have the values at the time of the Output statement execution.
You only have to worry about the "carrying forward" of the missing values within the current execution of The Do loop. Fi a new value is NOT assigned for a variable then yes it will have the same value as the previous pass through the loop.
All the values are reset with values for the next record from Set or Input statements. (Warning: Retain statement is designed to work around this behavior. OR if you have multiple Set or Input statements things could get very confusing quickly.)
In one of your other posts I recommended a way to output a bunch of new variables corresponding to each variable in your arrays so that a corresponding outcome was directly tied to the input instead of a simple flag that basically said "one of the conditions was met somewhere in the comparisons". I believe that approach lends itself in general to better analysis in many cases because then it has which and how many of the comparisons were met/failed instead of trying to create very complicated logic straight.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: