Questions tagged [do-loops]

a 'do' loop is a specific type of iteration used to run code repeatedly based on the evaluation of a boolean statement or variable.

do (while) loops in Java: https://docs.oracle.com/javase/tutorial/java/nutsandbolts/while.html

do loops in Fortran: https://en.wikibooks.org/wiki/Fortran/Fortran_control#Loops

do loops in Scheme: https://schemers.org/Documents/Standards/R5RS/HTML/

389 questions
0
votes
2 answers

Understanding Common Lisp do syntax

I have a little problem to understand do in lisp I have this code : (defun iota-b (n) (do ((x 0 (+1 x)) (u '() (cons x u))) ((> x n) (nreverse u)))) (iota-b 5) (0 1 2 3 4 5) In documentation there is the "do" basic template is: (do…
mpgn
  • 7,121
  • 9
  • 67
  • 100
0
votes
1 answer

Trouble with SAS do loop

This is my code: libname Project 'XXX'; run; %let dname = q1males; %let Gender = 'Male'; %let samp = q1msamp; %let stats = Malestats; data project.data1; set project.data; id = _n_; run; data project.&dname; set project.data1; if Gender =…
user2714330
  • 123
  • 1
  • 2
  • 7
0
votes
1 answer

SAS Do Loop: How to refer to an outside cell value

I have two questions regarding Do Loops in SAS. Say that I have three datasets: (1) one dataset, called last with one observation called last_observation: last_observation 150 (2) a second dataset with two columns of observations: Time ID 34200…
Plug4
  • 3,838
  • 9
  • 51
  • 79
0
votes
1 answer

%Do to iterate over a known set of character values in SAS

I would like to create a list of IDs (bee_created) that combine a treatment group (i), replicate (j) and serial number (k). I have 9 replicates to work on, each with slight variations in serial numbers in the treatment groups. So it would a lot more…
Chang
  • 11
  • 1
  • 5
0
votes
4 answers

Switch statement within Do-While loop doesn't exit

The code doesn't exit after I type "stop" - for some reason. Why? Step-by-step debugging shows that after I enter "stop" it's value consists of exactly 's','t','o','p' without any line breaks, etc. - however, the code still goesn't exit. Could…
evictorov
  • 33
  • 1
  • 12
0
votes
1 answer

Creating an autocomplete function, not showing every word

I am trying to create a mimic autocomplete, as the one jQuery provides is overloaded, and I don't want to use it that much. var easyBB = { spellCheck: function(boolean,options) { if(boolean === true){ $('textarea').on('keyup',function() { …
EasyBB
  • 6,176
  • 9
  • 47
  • 77
0
votes
2 answers

SED command inside a loop

Hello: I have a lot of files called test-MR3000-1.txt to test-MR4000-1.nt, where the number in the name changes by 100 (i.e. I have 11 files), $ ls test-MR* test-MR3000-1.nt test-MR3300-1.nt test-MR3600-1.nt test-MR3900-1.nt test-MR3100-1.nt …
Dox
  • 187
  • 1
  • 8
0
votes
1 answer

How do I return a value from inside a loop?

I am trying to read an XML file and store the structure into an array of objects. Here is my code: class Bike attr_accessor :id, :color, :name def initialize(id, color, name) @id = id @color = color @name = name …
Karthick S
  • 3,204
  • 6
  • 36
  • 52
0
votes
1 answer

How to get data and write to file?

I want to get blog01.xml from data01.xml, blog02.xml from data02.xml and so on. I'm trying with the following code, but it doesn't work. What is wrong?
0
votes
2 answers

Using an ARRAY Statement with an Iterative DO Statement

I'm working on a data set (DATA) which has 3 variables (Var1, Var2, Var3) in a format I need to change. The variables are in a special date format (for example purposes, say OLDFMT1) and I need to change them into regular SAS date format using the…
Mike L
  • 486
  • 5
  • 16
  • 33
0
votes
1 answer

How to compare date values in a macro?

Here is the macro I'm running.... %macro ControlLoop(ds); %global dset nvars nobs; %let dset=&ds; /* Open data set passed as the macro parameter */ %let dsid = %sysfunc(open(&dset)); /* If the…
SAS_learner
  • 521
  • 1
  • 13
  • 30
0
votes
1 answer

Confusion about "do-continue" and "go to-continue" in FORTRAN

Bad news Everyone, I recently started to learn FORTRAN to understand a code and translate it to C++ (I know what the code does is not important for this question, but to give some background, this code solves boundary value problems using…
triple_r
  • 1,037
  • 1
  • 8
  • 21
0
votes
1 answer

make openmp loop to combine small arrays into one big array

I have this loop which looks like the following in openmp but I am getting allocation errors: !$OMP PARALLEL DO PRIVATE(fn) do fn=0, NFILES allocate(temparray(1:3,1:Ntot)) LOAD temparray FROM FILE(fn) Ntot = len(temparray) …
Griff
  • 2,064
  • 5
  • 31
  • 47
0
votes
2 answers

How to call a function in a loop

I need to call a function in a loop. I have the following code.... do { var name = prompt("Enter name:"); if (!isNaN(age) && name != null && name != "") { names[i] = name; } loop = confirm("Add new name?"); i++; //…
0
votes
2 answers

Adding multiple numbers together from a list box c#

Im trying to add numbers together inside a list box. First of all i put the numbers inside the listbox into an array and integers. I now want to sum all the numbers together inside the list_box to give me a total. The way i was going to approach…
user1735367
  • 119
  • 1
  • 2
  • 6