What is the rule for the split?
At the third value? At a specific name? Something else not shown?
And show the code that you are currently using to "fetch from a table into a ',' separated macro ".
@khandelwalanmol wrote:
Rule is i have to keep 4 variables in the first variable and next 4 in another.
If in future the count of cities increase third variable shoukd be created.
You will want to switch to using a data step from trying to use SQL for this. So if you have variable named CITY in a dataset named HAVE you can use code like this to create macro variables MVAR1, MVAR2, ... and MVAR_COUNT.
data _null_;
do i=1 to 4 until(eof) ;
set have end=eof ;
length string $500 ;
string = catx(',',string,city);
end;
call symputx(cats('mvar',_n_),string);
if eof then call symputx('mvar_count',_n_);
run;
@khandelwalanmol wrote:
Rule is i have to keep 4 variables in the first variable and next 4 in another.
If in future the count of cities increase third variable shoukd be created.
Please check either your counting or your definition. The values you showed look like you start with 6 and want 3 value in each, not 4. So I am not sure how to interpret this "Rule".
@khandelwalanmol wrote:
Sorry for that typo.
It is 3 cities in one variable.
Then that looks like @Tom's solution starting with a "Do i=1 to 3" instead of the "to 4" should work.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: