LarrySteele
Programmer
I've been at this for a good couple of hours and I've surrendered.
Here's what I'm trying to do. I want to go through a loop n amount of times and build a string. Given an n[/n] of 5, I want to store the following: [tt]'School_1 Degree_1 School_2 Degree_2 ... School_5 Degree_5'[/tt]
I had something like this:
[tt]
DATA _NULL_;
DO I = 1 TO &IDX'
CALL SYMPUTX('CNT',I);
MY_STRING = MY_STRING || 'SCHOOL_&CNT DEGREE_&CNT';
END;
CALL SYMPUTX('MY_VAR',MY_STRING);
RUN;
[/tt]
When I ran this, I received the following:
[tt]
NOTE: Numeric values have been converted to character values at the places given
105:17
NOTE: Character values have been converted to numeric values at the places given
105:27
NOTE: Invalid numeric data, ' SCHOOL_&CNT DEGREE_&CNT', at line 105 column 27.
[/tt]
Line 105 is the MY_STRING=MY_STRING... line.
When I run this, I get the expected output:
[tt]
DATA _NULL_;
DO I = 1 TO &IDX'
CALL SYMPUTX('CNT',I);
MY_STRING = ' SCHOOL_&CNT DEGREE_&CNT';
END;
CALL SYMPUTX('MY_VAR',MY_STRING);
RUN;
[/tt]
The problem with the latter is that my output is ' SCHOOL_5 DEGREE_5'.
Just for fun, I tried this variation:
[tt]
DATA _NULL_;
DO I = 1 TO &IDX'
CALL SYMPUTX('CNT',I);
MY_STRING = 'SCHOOL_4 DEGREE_4' || ' SCHOOL_&CNT DEGREE_&CNT';
END;
CALL SYMPUTX('MY_VAR',MY_STRING);
RUN;
[/tt]
This version gave me the string I expected: 'SCHOOL_4 DEGREE_4 SCHOOL_5 DEGREE_5'. This tells me that the syntax of the string concatenation in my first version was correct. However, SAS was attempting to convert my string variable into a numeric variable and having a fit about it.
I tried wrapping the string with %STR(), but that didn't seem to change anything. I've tried Googling for some information, but I Couldn't think of anything useful to search on that didn't give me a billion false hits.
NOTE: We're using SAS (r) 9.1 (TS1M3) on z/OS (Read: this is on the mainframe).
Any assistance, suggestions, offerings would be appreciated. Answers would be doubly so.
TIA,
Larry
Here's what I'm trying to do. I want to go through a loop n amount of times and build a string. Given an n[/n] of 5, I want to store the following: [tt]'School_1 Degree_1 School_2 Degree_2 ... School_5 Degree_5'[/tt]
I had something like this:
[tt]
DATA _NULL_;
DO I = 1 TO &IDX'
CALL SYMPUTX('CNT',I);
MY_STRING = MY_STRING || 'SCHOOL_&CNT DEGREE_&CNT';
END;
CALL SYMPUTX('MY_VAR',MY_STRING);
RUN;
[/tt]
When I ran this, I received the following:
[tt]
NOTE: Numeric values have been converted to character values at the places given
105:17
NOTE: Character values have been converted to numeric values at the places given
105:27
NOTE: Invalid numeric data, ' SCHOOL_&CNT DEGREE_&CNT', at line 105 column 27.
[/tt]
Line 105 is the MY_STRING=MY_STRING... line.
When I run this, I get the expected output:
[tt]
DATA _NULL_;
DO I = 1 TO &IDX'
CALL SYMPUTX('CNT',I);
MY_STRING = ' SCHOOL_&CNT DEGREE_&CNT';
END;
CALL SYMPUTX('MY_VAR',MY_STRING);
RUN;
[/tt]
The problem with the latter is that my output is ' SCHOOL_5 DEGREE_5'.
Just for fun, I tried this variation:
[tt]
DATA _NULL_;
DO I = 1 TO &IDX'
CALL SYMPUTX('CNT',I);
MY_STRING = 'SCHOOL_4 DEGREE_4' || ' SCHOOL_&CNT DEGREE_&CNT';
END;
CALL SYMPUTX('MY_VAR',MY_STRING);
RUN;
[/tt]
This version gave me the string I expected: 'SCHOOL_4 DEGREE_4 SCHOOL_5 DEGREE_5'. This tells me that the syntax of the string concatenation in my first version was correct. However, SAS was attempting to convert my string variable into a numeric variable and having a fit about it.
I tried wrapping the string with %STR(), but that didn't seem to change anything. I've tried Googling for some information, but I Couldn't think of anything useful to search on that didn't give me a billion false hits.
NOTE: We're using SAS (r) 9.1 (TS1M3) on z/OS (Read: this is on the mainframe).
Any assistance, suggestions, offerings would be appreciated. Answers would be doubly so.
TIA,
Larry