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
2 answers

sas macro call macro

Hi I have a program to use one macro to call another one. I have two month(jun12 and jul12) and each month has two parts(1 & 2), I want to do a loop which I construct a macro called"Loop", Inside it, I constructed a Array, and used Do comment do…
user1652926
  • 85
  • 2
  • 5
0
votes
2 answers

SAS pass column name through variable

I need to pass a column name through a variable. %let dsn=a1234; data temp; set &a1234; if age>=20; run; Where 'a1234' is the column name (present in the file) that I want to use; and not the string a1234. The reason I want to do this is to…
jpsfer
  • 594
  • 3
  • 7
  • 18
0
votes
2 answers

SAS Compare Two Text Files (Unix / Windows)

I need to compare two text files (in different directories) to see if they are different (a binary result is fine). Given a dataset such as the one below, is this possible within a…
Allan Bowe
  • 12,306
  • 19
  • 75
  • 124
0
votes
1 answer

SAS: Proc Olap. Non-nway aggregation

I want to make Rolap-cube. After creation of tables, i use macro-generation to write Aggregation statement in proc olap. And see warning and error like this: WARNING: You cannot use NAME "DEFAULT" in the AGGREGATION statement for a non-NWAY …
gaussblurinc
  • 3,642
  • 9
  • 35
  • 64
0
votes
1 answer

How to set up autocall macros on a 9.3 Unix server

I'm using the enterprise version of SAS (v9.3) and want to set up some generic macros (for logging purposes) so that everyone in the department can use them. I know what I want is the autocall functionality, but the only information I can find is…
syntheticbrain
  • 288
  • 2
  • 13
-1
votes
3 answers

SAS how to replace a string with the name of a macro variable

I need to import multiple years' access tables into SAS. In each year's ACCESS DB, the table name has year as the suffix. For example: table2021. I first define a macro variable year. Then I am trying to replace the suffix of the table name to be…
Lin
  • 73
  • 8
-1
votes
2 answers

Is there a way to make this macro more efficiënt?

I will provide the macro below, in short what it does though. It takes a libname and gets all the columns in that libname. For each column name it gets the count(*) and count(columnname) so that we can check for missing values. Is there a more…
-1
votes
2 answers

How to move specific rows from an original table to a new table?

In SAS, I have a table that have 1000 rows. I am trying to separate that table into two tables. Row1-500 to Table A and row501-100 to table B. What is the code that can do this function. Thank you all for helping! I am searching the code online and…
Jason Qian
  • 11
  • 4
-1
votes
1 answer

Why is this macro contrasting Day_i with Day_(1-1) not working?

Why is this macro not working? %MACRO Cerved_recap; %let i=2; %DO i = 2 %TO &oggi.; %let ieri = %sysevalf(&i.-1); data work.initial_db_cerved; set work.initial_db_cerved; length esito_&i. $ 10; format esito_&i. $char20.; %if ENCOURS_TOTAL_&i. <…
-1
votes
1 answer

How to reduce time taken by sas macro code to run

I need help with my monthly report sas code below: Firstly the code takes too long to run while the data is relatively small. When it completes a message that reads: The contents of log is too large. Please can you check what the issue which my…
Tonas Max
  • 31
  • 4
-1
votes
1 answer

Can i use macro in the data step in sas?

I tried to use macro in data step to exclude rows that does not match the conditions, but it won't work. here is my code %macro bbb(a); data grade&a.; set grade&a.; if ID='schoolgrade&g.score1' then output; run; %mend; %match(4) so, i cannot use…
Arya
  • 1
  • 2
-1
votes
1 answer

Converting SAS custom user format to macro program

I have the following code that works properly in my SAS program to subset needed dates to shift hourly data but I need to convert to a macro so that I can call it for multiple data sets. I have very little experience in macro programming so any help…
C McCown
  • 67
  • 1
  • 7
-1
votes
1 answer

Creating variables from macro variables with increasing index in SAS

I am trying to create variables from macro variables with increasing index in a SAS macro but I am getting missing values for variables aa_index and I am getting 0 values for bb_index which should not bethe case. Please help with how I can adjust my…
ccc
  • 189
  • 1
  • 3
  • 12
-1
votes
1 answer

SAS macro to read multiple raw data files with no header and create multiple SAS dataset for each raw data file

I have multiple raw files without header . I want to automate the process in order to create multiples datasets and also once the dataset created need to automate the process when we use logic say **Actvity_flag ='Y'** , I need those datasets to be…
-1
votes
1 answer

Brings sets together into one data. (in macro) in SAS

i want to brings sets together into one data in macro. I have 1064 sets from zm_&next_name and i want to brings them into one data for example ----> data CramerSet; I want to do it in macro