Desktop productivity for business analysts and programmers

Definiy key variables as macro variable by using proc format

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 11
Accepted Solution

Definiy key variables as macro variable by using proc format

Hi All,

If I have this format

proc format;

VALUE $DOM

'AE' = 'USUBJID AETERM AESTDTC'

'CE' = 'USUBJID CETERM CESTDTC'

'CM' = 'USUBJID CMTRT CMROUTE CMSTDTC'

'DD' = 'USUBJID'

'DM' = 'USUBJID'

;

run;

 

I have the macro variables which take the value AE, CE etc, how can I definy a new macro variable which will take 'USUBJID AETERM AESTDTC' for AE??

 

Thanks


Accepted Solutions
Solution
‎09-21-2017 02:50 PM
Respected Advisor
Posts: 3,261

Re: Definiy key variables as macro variable by using proc format

[ Edited ]

For example

 

data _null_;
    call symputx("newmacrovariable",put("&origmacrovariable",$dom.));
run;

As a side issue (but it may be relatively important), you don't normally apply formats to macro variables, and it may be there's an easier way to achieve whatever it is you are doing without macro variables, or without formats. I can say more because I'd need a lot more details about what you are doing.

 

--
Paige Miller

View solution in original post


All Replies
Solution
‎09-21-2017 02:50 PM
Respected Advisor
Posts: 3,261

Re: Definiy key variables as macro variable by using proc format

[ Edited ]

For example

 

data _null_;
    call symputx("newmacrovariable",put("&origmacrovariable",$dom.));
run;

As a side issue (but it may be relatively important), you don't normally apply formats to macro variables, and it may be there's an easier way to achieve whatever it is you are doing without macro variables, or without formats. I can say more because I'd need a lot more details about what you are doing.

 

--
Paige Miller
Occasional Contributor
Posts: 11

Re: Definiy key variables as macro variable by using proc format

Posted in reply to PaigeMiller
Thanks so much..your code above gave me what I want. Actually I'm comparing old vs current transfer, I have the list of domains in a macro variable, I need to associate it with key variables.
Super User
Posts: 6,931

Re: Definiy key variables as macro variable by using proc format

%let newvar = %sysfunc(putc(&oldvar, $dom));

 

 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 172 views
  • 0 likes
  • 3 in conversation