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
3
votes
3 answers

How to tell SAS to compile a Macro each time it is called instead of doing it manually

Context: We use SAS 9.4 and Enterprise Guide 7.15. Currently, we are implementing some new Macros and of course have to change a lot along the way. Sometimes smaller, sometimes bigger changes. The problem is, that in order to get the changes to…
user190080
  • 525
  • 1
  • 8
  • 29
3
votes
2 answers

SAS PROC SQL - calculate a column using a value returned from macro program

I would like to automatize the following date calculation: add (or substract) X months to a given numeric variable that represents a date in the form YYYYMM, i.e. 201901 stands for January 2019. Example: 201901 + 13 months = 202002 The following…
Chuck Ramirez
  • 245
  • 1
  • 12
3
votes
1 answer

Passwordless authentication within SAS pass-through statements?

Thanks to SAS's Personal Login Manager, the initial connection to the remote server works without password (or password hash). However, it seems to be necessary to specify the passwords of the individual databases (user xxuser password xxpwd, see…
B--rian
  • 5,578
  • 10
  • 38
  • 89
3
votes
2 answers

SAS macro variable change + array index

This is related to this question: SAS macro variable change. The code below explains the problem: %macro test (arg=); options mlogic mprint symbolgen; array arraytwo [%EVAL(&arg+1)] _temporary_; sum=0; %do i = 1 %to %EVAL(&arg+1); …
francogrex
  • 465
  • 1
  • 4
  • 17
3
votes
1 answer

out of space SAS studio engine V9- MAC

I was trying to practice with a dataset having more than 100K rows and my SAS UE shows error as out of space while trying statistical analysis,after some google search I found some solutions like extending disk space in VM and cleaning work…
3
votes
2 answers

How to mask "OR" with variable list passed through using SYSPBUFF in macro

I'm using SYSPBUFF to pass through various numbers of parameters into a macro. Specifically, I am passing through a list of states. One of the states being used is Oregon or "OR" and that one state is causing me error. I get the error "ERROR: A…
MandyB
  • 81
  • 5
3
votes
3 answers

SAS Array creation

I am trying to create array that hold a value. proc sql noprint; select count(*) into :dscnt from study; select libname into :libname1 - :libname&dscnt from study; quit; I think the syntax is correct but i keep getting this following error message…
tita
  • 107
  • 1
  • 5
3
votes
1 answer

Prompt or Macro Variables used in calculations

I have created a numeric variable using the Prompt Manager in EG. This variable is called HYr for the highest year of data that I am pulling. When running the program I create 4 new variables based on the highest year and this is where I am having…
tbirkett13
  • 31
  • 1
3
votes
1 answer

Is it possible to loop through an entire process flow n times?

I'm currently working on an important project where we use logistic regression to predict events. The thing is, I need to generate 2 distinct sample of 1500 peoples then process a logistic regression. This whole process should be looped 50 times…
3
votes
1 answer

Does SAS have a macro to format output of user writen DI transformation?

When developing ETL programs with SAS Data Integration (DI) Studio, each transformation you specify has a neath user interface to specify the columns of the datasets(=tables) you create and their type, length and format. When the existing…
Dirk Horsten
  • 3,753
  • 4
  • 20
  • 37
3
votes
4 answers

How to pass variable sequence (list) to SAS Macro

I have variables named _200701, _200702,... till _201612, each containing specific numeric data for that month. From these, I want to substract specific amount (variable cap_inc), if a condition is met: %MACRO DeleteExc(var); DATA Working.Test; SET…
Gateux
  • 63
  • 6
3
votes
2 answers

rename SAS variables in reverse order using do loops

I have 10 variables (var1-var10), which I need to rename var10-var1 in SAS. So basically I need var10 to be renamed var1, var9 var2, var8 var3, and so on. This is the code that I used based on this paper,…
llsabang
  • 143
  • 1
  • 10
3
votes
1 answer

SAS: leaving ampersand in a macro variable

This should be an easy one, but I can't figure it out: there are situations where I need to create a macro variable from contents of a table, and they sometimes contain ampersands (&) as part of the text. How do I get SAS to ignore the ampersands…
Eric
  • 53
  • 1
  • 5
3
votes
4 answers

Macro execution for only odd values

I am trying to implement a macro that takes only odd values into the algorithm. My strategy thus far is as follows: %macro TEST; %do i=1 %TO 5; %IF %SYSFUNC(MOD(&i,2)=1) %THEN %DO; ALGORITHM %END %END %MEND…
falling_up
  • 81
  • 9
3
votes
1 answer

How to determine what folder is the SAS macro stored in

I have a program (it was developed by my colleagues) with 20 paths in SASAUTOS. So, when I see calling of some macro in the code I can't easily determine what folder the macro is stored in. Is there some function for this purpose or system table…
PierreVanStulov
  • 425
  • 2
  • 11