12-15-2015 02:48 AM - edited 12-15-2015 02:50 AM
May be you will like to try something as below
I used the quote function to quote the individual values and used strip to remove the trailing spaces.
select distinct strip(quote(name)) into :names separated by ' ' from sashelp.class;
12-15-2015 05:31 AM
For what purpose, and what type of data? If you want to do sql in's then use a table:
proc sql; create table WANT as select * from HAVE where AVARIABLE in (select CODE from CODELIST); quit;
If you need a list of data for any purpose a dataset is a far better storage unit for it. Even if somewhere down the line you really have to do it witha macro list (and I have never come across a scenario where there isn't a better method) then you would just use sql select into separated by. However bear in mind the limitations with such a process, and error checking - maybe the data contains quotes/specials etc.
12-15-2015 05:41 AM
12-15-2015 05:49 AM
I am beginning to suspect with your questions that you want the community to write an entire macro library based off some idea you have to do everything in macro code, is this the case?
12-15-2015 06:34 AM
Could I suggest then that you first start by learning Base SAS:
Is a good start, then maybe some other courses. Understanding of "where" macro language should be used is as important as "how" it should be used. As mentioned, in all of your posts so far, it has not been so much of a question / answer request but more of a please provide code to do XYZ. Understanding of how to do things in Base SAS - which is the underlying programming language will solve most, if not all of the tasks you are trying to do. Once you have that down, you can then start to tlook at what conponents could be more useful as macros, and what systems require. Follow Software Development Lifecycle process also, develop a document which details the full process, then break that process out into separate processes, create functional design specifications for each process which would detail data flow, checks which need to be performed etc. Once you have docuemented the entire thing, then it should be a simple matter to write some code to action those documented processes. Forcing code into macro, especially if you do not understand it, and have no clear concept to follow is a recipe for disaster.
Rule no 1 for coding:
Plan, document, implement, test.
With regards to providing code, consider hiring a contractor to create code based on your FDS if you need to.
12-15-2015 06:41 AM
12-15-2015 08:32 AM
%macro put_quotes_around(string=); %local ii nwords newstring; %let nwords=%sysfunc(countw(&string)); %let newstring=; %do ii=1 %to &nwords; %let thisword=%scan(&string,&ii,%str( )); %let newstring=&newstring %str(%')&thisword%str(%'); %end; %unquote(&newstring) %mend; %let newmacrovar=%put_quotes_around(string=ABC DEF GHI); %put NEWMACROVAR &newmacrovar;
12-16-2015 12:18 PM
How are your values delimited? Are there spaces within the values you want quoted?
A one minute search on Google for Sas macro variable lists would give you many examples starting with http://www2.sas.com/proceedings/forum2007/113-2007.pdf