Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...This site is like first coffee in the winter morning..."

Geography

Where in the world do Tek-Tips members come from?
jorondo (Programmer)
23 Jul 12 11:24
I am stuck trying to read a macro variable containing a list of values by using the %scan function to find which list is going to be scanned for a value. Here is an example:

1. I have the following list;
%let list_cci=MI CHF CVD PVD DEM CPD CTDRD PUD MLD diab_wc diab_c P_H RD CAN MSLD MC HIV;

2. Each value of this list is another list, as following:
%let MI=410 412;
%let CHF=39891 40201 40211 4291 40401 40403 40411 40413 40491 40493 4254 4255 4257 4258 4259 428;
...

3. The idea is that I want to scan the list, assign a value to a macro variable, and then use that macro variable to tell sas which list to scan for another value. I need to do this in 2 steps because the variable name (MI, CHF, CVD, etc.) is important. However, when

4. Here is what I have done so far, within 2 %do loops that run from 1 to &i and &j:

%let diagname = &%scan(&list_cci.,&i.);
%put &diagname; /*gives me e.g. &MI */

%let var=%scan(&diagname,&j.); /*--->here I expect it would scan the MI list, because &MI is put in the %scan function*/

%put &var; /* but all I get is the jth value from the &list_cci list... even though %put &diagname; gives me &MI!*/

Any ideas why it would scan the first list when I ask to basically %scan(&MI,&j.)? Any other idea how I could solve this?
sasbuddy (Programmer)
25 Jul 12 1:25
I am not exactly clear with the requiremnt;
But hopefully it would work fine using call symput instead of using %let in macro code.
I would suggest use a data _NULL_ statement inside that use call symput plain scan function.

sasbuddy
http://sites.google.com/site/sasbuddy/

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close