How to create symbols from strings and set values for them?

One solution is to use the third argument of ToExpression:

With minimal modification, a working version of your code would look like this:

Table[
  ToExpression[
  mmsignalnames[[i]], 
  InputForm, 
  Function[name, 
    name = Extract[ToExpression[celfilenames[[i]]], mmammindices[[j]]],
    HoldAll]],
 {i, Length[mmsignalnames]}, {j, Length[mmammindices]}]

(Untested because I don't have your data; but see below for the main idea and a small demonstration.)

The core of the method is this:

ToExpression["a", InputForm, Function[name, name = 1, HoldAll]]

ToExpression will wrap the result into its third argument before evaluating it. We can make the third argument a function that sets a value to the symbol (in this simple example it always sets the value to 1). HoldAll is needed to make sure the symbol won't evaluate when it is passed to the function.


You might find all the evaluation control I'm using here a bit confusing. To learn how to work with unevaluated expressions, I recommend reading

  • Working with Unevaluated Expressions by Robby Villegas

It is one of the best tutorials on the matter.


Finally, after answering your actual question, I'd like to suggest you use a hash table instead of symbols:

Instead of creating symbols from the strings "a", "b", "c", ..., and assigning to them, you could assign to myTable["a"], myTable["b"], ... This will make programmatic access to this data trivial. You won't need to bother with evaluation control nearly as much. And more importantly, you can avoid accidental name collisions with existing symbols. Here's an example:

(myTable[#] = 1) & /@ {"a", "b", "c"}

So recently I've learned from John Fultz that RawBoxes are kind of verbatim indicator for MakeBoxes which is not well stressed out in documentation.

This or I've missed the point but it doesn't matter, here we have handy way to do this:

x = 5;
ToExpression @ MakeBoxes[RawBoxes["x"] = 123];
x
123

You need to make the left-hand side of Set a symbol at the time of evaluation. Use With or similar to inject the symbol:

mmsignalnames = {"one", "two", "three"};

With[{lhs = Symbol[mmsignalnames[[2]]]},
 lhs = 5
];

two
5

Another approach that could be important if you are trying to make assignments to symbols that already have values is this:

Function[{lhs}, lhs = 7, HoldAll] @@ MakeExpression[ mmsignalnames[[2]] ] ;

two
7

Or a bit more terse using the "injector pattern":

MakeExpression @ mmsignalnames[[2]] /. _@x_ :> (x = 9);

two
9

Also, it bears mentioning that one may also use indexed symbols such as

name["two"] = 5;

name["two"]
5

For another approach to this kind of problem see: