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
2
votes
1 answer

How to log the current step in SAS?

I'm trying to monitor the progression of a long SAS script. At the beginning, I used something like: DATA work.dataset1; SYSECHO "Currently working on: work.dataset1"; /* DO STUFF*/ END; PROC SORT DATA=work.dataset1 OUT =…
Théophile Pace
  • 826
  • 5
  • 14
2
votes
1 answer

SAS - Looping Macros

I am trying to automate a process in SAS that alters the value of a variable in a dataset iteratively and calculates another variable for each. I am trying to get that to work as a macro within a loop, where the parameters in the inner Macro are…
cc143
  • 23
  • 2
2
votes
2 answers

SAS variable concatenation through data step

I am looking for a way to create a string variable containing certain values of the dataset while going through the data step. Example data set work.test: AddToStringYN Value Y One Y Two N Three Y…
Yoh
  • 678
  • 1
  • 10
  • 18
2
votes
2 answers

Use a macro instead of 25 proc sql steps?

I have a SAS code (SQL) that has to repeat for 25 times; for each month/year combination (see code below). How can I use a macro in this code? proc sql; create table hh_oud_AUG_17 as select hh_key ,sum(RG_count) …
Kirstenz
  • 21
  • 2
2
votes
2 answers

How keep the layout of an HTML textarea when past in SAS macro variable?

I create a custom input form for a SAS Stored Process which produce a report and send it in a mail. In a first screen, a form is display and I have a text area where user will be able to write some texts and this text will be display above the…
William
  • 91
  • 1
  • 1
  • 6
2
votes
0 answers

Not able to log off user sessions in SAS

In SAS Customer Intelligence, there are user sessions under Administration tab as shown below. The problem is there are few sessions of previous day which are not getting logged of. To let you know I've already cleared all Unxsrv sessions by killing…
2
votes
2 answers

Parallel Processing in SAS

oh wise StackOverflow users. I have a question about parallel processing in SAS 9.4: I'm aware that SAS typically executes procedures in a sequential, or linear manner, however, I am also aware that SAS is capable of executing procedures in parallel…
2
votes
2 answers

SAS Vlookup in the same table

my case is finding value in this same table (for Variable2 from Value). Can you help me? I need a SAS code for this case. I tried to solve this way: data example2; input Variable Value…
2
votes
2 answers

Dynamic n in function LAG (variable) SAS

do you know how to use n in function LAGn(variable) that refer to another macro variable in the program-> max in my case? data example1; input value; …
2
votes
1 answer

SAS macro loop until obs count >0

I'm trying to automate a scheduled event in SAS so that when the SAS program opens it first runs a pass through query that creates a local table. I want this query to keep running in a loop until the observation count of that table is >0. The idea…
nbwest76
  • 49
  • 1
  • 2
  • 12
2
votes
2 answers

SAS Macro in macro

I have one question regaring %macro. Can I set %macro in another %macro? Short example - "picture" of situation: %macro Tier_1(); %do Iter = 1 to &i; %macro Tier_2() proc sql noprint; select 1*&Iter into :var …
DarkousPl
  • 85
  • 1
  • 10
2
votes
4 answers

Create several SAS macro variable lists from single dataset

Since the the length of the value of a macro variable cannot exceed the maximum length of (65534), I can't create a single macro variable for all of my observations. I would like to create a macro to iterate through my data set to generate several…
2
votes
3 answers

How to pass an %LET argument into a sas script from R?

I have an R script that let me run a macro in SAS, like this (inspiration from here): setwd("C:/myplace") sas_script <- "MyScript.sas" sas_log <- tempfile() sas_out <- tempfile() cmd <- sprintf( 'sas.exe -nosplash -icon -sysin "%s" -log "%s"…
Jeppe Olsen
  • 968
  • 8
  • 19
2
votes
2 answers

A lock is not available for MYLIB.SASMACR.CATALOG

I have a library of stored compiled macros, i.e. macros that I define like this : options mstored sasmstore=MYLIB; %macro say_something(txt) / STORE SOURCE; %put &txt; %mend; I'm often getting this error message : NOTE: The SAS System was unable…
moodymudskipper
  • 46,417
  • 11
  • 121
  • 167
2
votes
1 answer

how to include a do loop inside a macro in SAS?

Following is an example of the data-set I have data have; input institution$ GPA; cards; A 3.2 AB 3.4 BC 4.0 DF 3.2 A 4.0 A 3.0 A 3.5 A 3.7 A 3.8 F 3.8 D 3.2 D 3.1 D …
Nathan123
  • 763
  • 5
  • 18