Популярное

Музыка Кино и Анимация Автомобили Животные Спорт Путешествия Игры Юмор

Интересные видео

2025 Сериалы Трейлеры Новости Как сделать Видеоуроки Diy своими руками

Топ запросов

смотреть а4 schoolboy runaway турецкий сериал смотреть мультфильмы эдисон
dTub
Скачать

How to Use SAS - Special Topic - Macro Coding and Macro Variables

Автор: Mike's SAS Tutorials

Загружено: 2012-02-02

Просмотров: 134757

Описание:

Bitcoin donations are welcome: 1GGV3gbJeA83FWmz9hDfPri8EuqcUtodXy

Mike's SAS Tutorials - Special Topic 1

This video series is intended to help you learn how to program using SAS for your statistical needs. This special topic lesson introduces the concept macro programming to accomplish repetitive tasks more easily. I also discuss macro variables, and the concept of passing variables into the macro function. I provide basic methods of converting a simple set of procedures into a macro that can be used as a template to repeat those procedures for any variable. Finally, I work through an example to show how one can use macros to take a variable and create several transformations of it.

Helpful Notes:

1. There are two places one can use macro variables: within a macro, and globally outside of all STEPS.

2. The ampersand operator: &, defines a macro variable within a macro and is used to call macro variables anywhere.

3. The %let statement allows you to define macro variables outside of a macro, though the & operator still must be used to call the macro variable elsewhere.

4. The MACRO statement begins the definition of a macro and the MEND ends the definition.

5. It is optional to restate the macro name after the MEND statement.

6. A macro can be thought of as a function, where one passes something into the function and certain things are returned. Unlike a function, however, macros do not always have to return something.

Today's Code:

data main;
input ID var1 var2;
cards;
1 2 3
2 4 5
3 6 7
4 8 9
;
run;

proc contents data=main; run;

/* 1. Create a macro variable using the %let statement */
%let newvar = var3;

/* 2. Use the & operator to call a macro variable */
data new_main; set main;
&newvar = var1+var2;
run;

proc contents data=main; run;
proc contents data=new_main; run;

proc print data=new_main;
run;

/* 3. Create a macro to transform a variable */
%MACRO transform_this(x);
&x._squared = &x ** 2;
&x._cubed = &x ** 3;
&x._inverse = 1 / &x;
%MEND transform_this;

data newer_main; set new_main;
%transform_this(var1);
%transform_this(var2);
run;

proc print data=newer_main;
run;

/* 4. Create a macro to run the CONTENTS procedure on any data set */

proc contents data=main; run;
proc contents data=new_main; run;
proc contents data=newer_main; run;

%MACRO contents_of(data_set);
proc contents data=&data_set; run;
%MEND contents_of;

%contents_of(main);
%contents_of(new_main);

How to Use SAS - Special Topic - Macro Coding and Macro Variables

Поделиться в:

Доступные форматы для скачивания:

Скачать видео mp4

  • Информация по загрузке:

Скачать аудио mp3

Похожие видео

How to Use SAS - Special Topic - Configuring the SAS Environment for Efficiency

How to Use SAS - Special Topic - Configuring the SAS Environment for Efficiency

Why the Radius Is NOT 21 – Quarter Circle Geometry Puzzle

Why the Radius Is NOT 21 – Quarter Circle Geometry Puzzle

Starship Simulator - Random Friday! - Comms Gameplay

Starship Simulator - Random Friday! - Comms Gameplay

SAS Tutorial | 3 Steps to Build a SAS Macro Program

SAS Tutorial | 3 Steps to Build a SAS Macro Program

How to Use SAS - Lesson 1 - The SAS Interface

How to Use SAS - Lesson 1 - The SAS Interface

SAS Tutorial | How to Create Macro Variables and Use Macro Functions

SAS Tutorial | How to Create Macro Variables and Use Macro Functions

Музыка для глубокого фокуса для улучшения концентрации — 12 часов эмбиентной учебной музыки для конц

Музыка для глубокого фокуса для улучшения концентрации — 12 часов эмбиентной учебной музыки для конц

How to Use SPSS - Lesson 1 - The SPSS Environment and Variable Properties

How to Use SPSS - Lesson 1 - The SPSS Environment and Variable Properties

SAS- Proc Transpose-1

SAS- Proc Transpose-1

How to Use SAS - Lesson 4 - Merging Data Sets

How to Use SAS - Lesson 4 - Merging Data Sets

НАЧАЛО ГОДА СУЛИТ НОВЫЕ ПРОБЛЕМЫ YOUTUBE, GOOGLE и отключения ИНТЕРНЕТА. Разбираем важное

НАЧАЛО ГОДА СУЛИТ НОВЫЕ ПРОБЛЕМЫ YOUTUBE, GOOGLE и отключения ИНТЕРНЕТА. Разбираем важное

How to Use SAS - Special Topic - Working with SAS Datetime Data

How to Use SAS - Special Topic - Working with SAS Datetime Data

Part 1:  Using Proc SQL to create and use arrays in macros in SAS.

Part 1: Using Proc SQL to create and use arrays in macros in SAS.

SAS Tutorial | How to convert character to numeric in SAS

SAS Tutorial | How to convert character to numeric in SAS

How to Use SAS - Lesson 5 - Data Reduction and Data Cleaning

How to Use SAS - Lesson 5 - Data Reduction and Data Cleaning

Как счёты вычисляют числа? Деревянная рама, изменившая математику (1226)

Как счёты вычисляют числа? Деревянная рама, изменившая математику (1226)

How to Use SPSS - Lesson 2 - Importing External Data

How to Use SPSS - Lesson 2 - Importing External Data

Введение в SAS — Что такое SAS (Модуль 01)

Введение в SAS — Что такое SAS (Модуль 01)

Call Symput

Call Symput

How to Use SAS - Lesson 8 - Paired and Two-Sample t Tests

How to Use SAS - Lesson 8 - Paired and Two-Sample t Tests

© 2025 dtub. Все права защищены.



  • Контакты
  • О нас
  • Политика конфиденциальности



Контакты для правообладателей: infodtube@gmail.com