Questions tagged [sas-macro]

A metaprogramming language used in the SAS suite to modify normal SAS code at run-time.

SAS Macro language offers more flexibility for programming SAS code. SAS code written with SAS Macro will be compiled before execution. SAS Macro language uses % for calling SAS macro functions and for calling and defining macros, e.g.:

%macro temp;
  %put %sysfunc(date());
%mend;
%temp;

Variables are used with &, e.g.:

%let my_var = "Hello World";
%put &my_var.;

More about

1265 questions
0
votes
1 answer

frequency of the variable

prg below tries to count the instances of variables. %macro freq(dsn=,variable=,freq=,label); proc freq data = &dsn; tables &variable; run; %mend; %freq(dsn=fff,variable=ggg);
Apache11
  • 189
  • 11
0
votes
2 answers

Display a range if a value is in the range else if value is less or greater than range display '$'

I have numeric data i want to code a generic macro to display a range if the numeric variable value is falling in the range else if value is less or greater than range range then display '$$$'.
Apache11
  • 189
  • 11
0
votes
1 answer

How to use the && macro variable in SAS

I'm working with SAS and I have to create some macro variables within a DO loop. This is a portion of my code: %if &dsempty888=0 %then %do; data _null_; set freq_&&var&i; if &&var&i=888888888 then do; call…
0
votes
1 answer

SAS - The internal source spool file has been truncated - YHQSRC/XZPWRIT failure

I've found failure message log unknown for me. There is simple macro-code which works correctly for a long time. What does it mean? NOTE: The internal source spool file has been truncated. Error logging with line and column information may be…
andrey_sz
  • 751
  • 1
  • 13
  • 29
0
votes
1 answer

SAS: apparent symbolic reference not resolved

I have a problem with unresolved variables in this part of a macro: %MACRO tukeyaddit(dataset=, factor1=, factor2=, response=); ods listing close; proc glm data=&dataset; class &factor1 &factor2; model &response = &factor1 &factor2; ods…
0
votes
1 answer

sas run if statement over macro variables

I have the following two sas datasets: data have ; input a b; cards; 1 15 2 10 3 40 4 200 1 25 2 15 3 10 4 75 1 1 2 99 3 30 4 100 ; data ref ; input x y; cards; 1 10 2 20 3 30 4 100 ; I would like to have the following dataset: data want ; …
user2568648
  • 3,001
  • 8
  • 35
  • 52
0
votes
2 answers

Call a macro from a macro in SAS

I am trying to use this macro to run different sections of code. When I select and run the %if statements by themselves, they work. However, when I try to run the %begin macro, SAS EG immediately tells me the program is finished with no errors.…
theponcer
  • 49
  • 1
  • 9
0
votes
2 answers

Macro to loop through variables and store results SAS

I have the following variables: A_Bldg B_Bldg C_Bldg D_Bldg. I want to multiply them by INTSF and store the result in a new variable, Sale_i. For example, A_Bldg * INTSF = Sale_A, B_Bldg * INTSF = Sale_B, and so on. My code is: %macro…
natnay
  • 460
  • 1
  • 5
  • 24
0
votes
1 answer

SAS macro variables in PROC MIXED

This is my first foray into using SAS macros, and I'm following this page from the amazing UCLA Stats Consulting Group. I'm interested in using macro variables in PROC MIXED to avoid copying and pasting blocks of code (my actual data set has ~400…
emudrak
  • 789
  • 8
  • 25
0
votes
2 answers

How to create a macro variable within a macro?

I am wondering how to create a SAS macro variable within a block of SAS %MACRO statement? It appears that my CALL SYMPUT or my SELECT INTO statements aren't working when they are in a block of %MACRO statement. %MACRO…
Roger Luo
  • 19
  • 6
0
votes
2 answers

colon and vertical bar in SAS

New to SAS. I know the following codes are creating a macro variable that stores a list of variables names, but what do : and | mean? %let v_lst = a b bb: t_v129 | c tt: t_v16 t_v275 | d: t_v56 | ;
user3075021
  • 95
  • 1
  • 8
0
votes
1 answer

sas passing quoted strings to a macro

so I have a dataset whose elements are strings of emails in quotes. A single data element might look like this: "john@cool.com" "jacob@cool.com" "jingleheimer@cool.com" "smith@cool.com" I have the following macro command and data step: %macro…
Jesse_m_m
  • 185
  • 1
  • 9
0
votes
1 answer

SAS: Non-sequential do loop within a data step

I would like to be able to execute a do loop for a non-sequential set of values. The way I have written this code runs a new data step for each value - so therefore the end product is a data table with a column added for the final value of the do…
green2010
  • 21
  • 2
0
votes
2 answers

use a character date string as a date in data step

I have the following two macro variables: %let start_date = 29MAY2014; %let end_date = 15JUL2014; I would like to create a dataset which is a series of dates between these (inclusive.) I cannot change the input format of the macro variables…
datavoredan
  • 3,536
  • 9
  • 32
  • 48
0
votes
2 answers

How to create Macro variable for each unique region and assigned minimum amount to respective macro variable

I have a dataset which have three variable.below is the example dataset. Id Region Amount 1 A 20 1 A 40 1 A 50 2 B 40 2 B 30 2 B 60 3 C 10 3 C 30 4 D 20 4 D 50 4 D 10 I want to create macro variable for…