Hi,
can someone tell me why that
data new;
do map = 1 to 7;
output;
end;
char_map= put(map,4.);
run;
doesn't do what it should, namely to change from numeric to character/string? (need it to map with another column which is a string... ) Thanks!
I think there is an order of operations issue. The output is within the loop and BEFORE the conversion.
Some concepts:
data new;
do map = 1 to 7;
char_map= put(map,4.);
output;
end;
run;
@newbie69 wrote:
Hi,
can someone tell me why that
data new;
do map = 1 to 7;
output;
end;
char_map= put(map,4.);
run;doesn't do what it should, namely to change from numeric to character/string? (need it to map with another column which is a string... ) Thanks!
Since your PUT function comes after the OUTPUT statement, nothing from PUT is ever output to the data set. Perhaps this is what you want:
data new;
do map = 1 to 7;
char_map= put(map,4.);
output;
end;
run;
Now because PUT comes before output, the results of PUT are written to the data set.
And so really, your subject line is wrong, this problem has nothing to do with the data type of the variable. Probably best not to jump to conclusions about the cause, and just simply use a subject line like "PUT statement not working" and ask how to fix it to give the desired result.
I think there is an order of operations issue. The output is within the loop and BEFORE the conversion.
Some concepts:
data new;
do map = 1 to 7;
char_map= put(map,4.);
output;
end;
run;
@newbie69 wrote:
Hi,
can someone tell me why that
data new;
do map = 1 to 7;
output;
end;
char_map= put(map,4.);
run;doesn't do what it should, namely to change from numeric to character/string? (need it to map with another column which is a string... ) Thanks!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.