Тёмный

SAS Tutorial | Beyond the Basics of Macro 

SAS Users
Подписаться 32 тыс.
Просмотров 30 тыс.
50% 1

Do you use programs containing ampersands and percent signs? If so, you are using SAS macros. The macro facility allows you to perform text substitution using macro variables and macro programs. Macros make life easier for the programmer by automating and customizing the generation of SAS code. In this SAS tutorial, John will demonstrate a basic understanding of the macro facility by starting with a review of the %LET statement, CALL SYMPUTX routine, INTO clause, macro conditional and iterative processing statements and macro program syntax. He will also discuss double periods, multiple ampersands, macro quoting and the macro IN operator. He’ll wrap up with examples of I/O functions, dictionary tables, the DOSUBL function and branching within a macro program.
Content Outline
0:00:28 - Macro Basics: The Straightforward Basics
0:40:45 - Demo: Macro Basics, The Straightforward Basics
1:23:00 - Macro Basics: The Not So Straightforward Basics
1:58:00 - Doing More with Macro
2:25:00 - Demo: Doing More with Macro
2:37:00 - Closing Remarks
Learn more about SAS Software
Macros Tip: %INCLUDE vs. Macro Language blog - blogs.sas.com/content/sastrai...
Free SAS Online Training - www.sas.com/en_us/training/of...
Contact SAS® - www.sas.com/en_us/contact.geo...
SUBSCRIBE TO THE SAS USERS RU-vid CHANNEL #SASUsers #LearnSAS #SASGF
ru-vid.com?sub_...
ABOUT SAS
SAS is a trusted analytics powerhouse for organizations seeking immediate value from their data. A deep bench of analytics solutions and broad industry knowledge keep our customers coming back and feeling confident. With SAS®, you can discover insights from your data and make sense of it all. Identify what’s working and fix what isn’t. Make more intelligent decisions. And drive relevant change.
CONNECT WITH SAS
SAS ► www.sas.com/contact
SAS Customer Support ► support.sas.com
SAS Communities ► communities.sas.com
SAS Analytics Explorers ► explorers.sas.com
Facebook ► / sassoftware
Twitter ► / sassoftware
LinkedIn ► / sas
Blogs ► blogs.sas.com
RSS ►www.sas.com/rss

Наука

Опубликовано:

 

30 июн 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 50   
@beans802
@beans802 3 года назад
I could watch this man talk for far more than 2.5 hours.
@jaxlee4661
@jaxlee4661 2 года назад
Perfect video introducing all the basic information about SAS Macro! Thanks for sharing!
@SASUsers
@SASUsers 2 года назад
Glad you enjoyed it!
@nodrogguod
@nodrogguod 4 года назад
Thanks for the vieo, two and a half hours well spent on learning!
@sanketkamat5983
@sanketkamat5983 2 года назад
Such an amazing video. Although have been using macros this video enlightened me with so many new features. Thanks for sharing this!
@SASUsers
@SASUsers 2 года назад
We're glad you enjoyed it!
@femiogunyemi2688
@femiogunyemi2688 4 года назад
Thanks for the lessons ,this video l watched advance me to know more on macro work and services it provide .
@xuefeng1982
@xuefeng1982 Год назад
Thank you so much for the very detailed explanation, the best learning materials I had so far!!!
@SASUsers
@SASUsers Год назад
You're welcome, Xue, we're thrilled it was so helpful for you! Thank you for such wonderful feedback - we'll be sure to share it with John!
@jessicasonbert6967
@jessicasonbert6967 Год назад
So helpful - thank you so much for posting!!!
@adityavarma1792
@adityavarma1792 4 года назад
Thank you. Got to learn some new ways n functions. 👍
@niyazshaik4178
@niyazshaik4178 3 года назад
Great work....Thank you sir
@SASUsers
@SASUsers 3 года назад
Niyaz, glad you found it helpful!
@jinpenggao1943
@jinpenggao1943 3 года назад
It is an awesome lecture, Thanks1
@SASUsers
@SASUsers 3 года назад
Glad you liked it!
@zbigniewz.lewandowski8629
@zbigniewz.lewandowski8629 2 года назад
Great, great and great!
@SASUsers
@SASUsers 2 года назад
So glad you found in helpful! 🙂
@vvvvv432
@vvvvv432 2 года назад
Great tutorial! Just a question :Is the code material included in the video available to download?
@SASUsers
@SASUsers 2 года назад
Thank you for your inquiry! Vagelis, we are checking on this for you!
@SASUsers
@SASUsers 2 года назад
Hi Vagelis, most of the demos in this tutorial use SASHELP data sets, which are available with every SAS installation. So you should be able to run the programs without needing any extra data. The programs used by the instructor in this tutorial are not available for download. For more formal training, you might want to look at our Macro 1 2.sas.com/6053JWPa5 and Macro 2 2.sas.com/6054JWPag classes.
@yandisanovokoza4320
@yandisanovokoza4320 3 месяца назад
I would have loved to access the codes if they were saved somewhere, otherwise this i real enjoyed
@SASUsers
@SASUsers 3 месяца назад
We're glad you enjoyed it and will pass along your feedback!
@muhammadhesham8120
@muhammadhesham8120 Год назад
Thank You
@muhammadhesham8120
@muhammadhesham8120 Год назад
@@fadwa2413 علي Coursera في كورس عن ال macro variables
@SASUsers
@SASUsers Год назад
مرحباً فدوى، تفضلي بالروابط التالية المتعلقة ب Macros: SAS Macro Programming for Beginners: 2.sas.com/6058Me3Wu Macro Language Trainings: 2.sas.com/6050Me3Wr
@SASUsers
@SASUsers Год назад
أهلا وسهلا بك فدوى، استمتع!
@dritans7334
@dritans7334 3 года назад
It was great explanation. One thing I didn't understand is why we write the column =: in this step memname=:"%upcase(&dsnstart)";
@SASUsers
@SASUsers 3 года назад
Checking on this for you!
@SASUsers
@SASUsers 3 года назад
We contacted the video presenter, and he searched through the programs used for this presentation. He could not find any reference to the code snippet you asked about: "memname=:"%upcase(&dsnstart)". Can you provide the time stamp in the video where you see a reference to the macro variable &dsnstart and the line of code you're asking about? We reviewed the section on working with dictionary.tables and dictionary.columns. One of the variables, MEMNAME, is used in that section to illustrate working with SQL dictionary tables. The values stored in the MEMNAME column are ALWAYS stored in uppercase. So in this code snippet you posted, the %upcase macro function is being used to transform the value of the macro variable &dsnstart from how it was specified originally into upper case for the purposes of the comparison. If this is not what you were asking about specifically, you'll need to let us know exactly where in the video you found the text string. Sound good?!
@dritans7334
@dritans7334 3 года назад
@@SASUsers I am sorry for not mentioning the time stamp before. I appreciate the availability you are showing. It is used in 2:17:35 time stamp, at line 5. What is the purpose of using : after = sign instead of just an equal sign? It is used and memname =: "%upcase(&dsnstart)";
@SASUsers
@SASUsers 3 года назад
Thank you. We will get back to you shortly.
@SASUsers
@SASUsers 3 года назад
Thanks for that time stamp. We found the code. The use of the colon with an = sign is unique to SAS syntax. It is a way of limiting the comparison. So for example, only the first 2 characters of the value will be compared. In the macro program, the value for &dsnstart is set to the lowercase value pr. That value needs to be used with %upcase so that the first 2 characters of the comparison look for PR. Using the =: syntax is explained on this page: 2.sas.com/6054Hi8Gp under the section on Character Comparisons. One way to think of it is like asking for a "starts with" comparison. So on the slide, the macro program will write code that can be submitted and the resolved code for the WHERE statement will look like this: where libname="SASHELP" and memname=: "PR"; As you can see, by the time the code is sent forward for execution, both of the macro program parameters, sashelp and pr, will be uppercased and the comparison of =: is telling SAS to only select data from SASHELP.VTABLE where the LIBNAME is SASHELP and the member name or table name has the first 2 characters equal to PR. This means that SASHELP.PRDSALE and SASHELP.PRICEDATA would meet these criteria, but another dataset named SASHELP.APRIL would NOT be selected because the first 2 characters are AP, not PR. (Note, if you type and run this program, there is NOT a SASHELP.APRIL dataset that name was picked for illustration purposes only.) If you want to learn more about comparison operators and the WHERE clause and the WHERE statement, we recommend the Programming 1 class, which is free as self-paced e-learning. You can read the description of Programming 1 here: 2.sas.com/6055Hi8GV . Hope this helps, Dritan!
@srikanthreddy3454
@srikanthreddy3454 Год назад
For creating output dataset in proc means we use output out,but in proc freq we use only out,both are procedures only but why there is that difference, please explain
@SASUsers
@SASUsers Год назад
Thank you for your inquiry! We are checking in to this for you!
@SASUsers
@SASUsers Год назад
Hi Srikanth, This video discusses Macro topics, not the reasons behind differing syntax for MEANS vs FREQ. And, the fact is that there just is different syntax. The original SAS procedures were written at different times in the development of SAS and many procedures have different methods to output a data set. Basically, some procedures use the OUT= option and some use the OUTPUT statement. You need to look at the documentation for each procedure to see what the internal procedure syntax is for creating an output dataset. The fact is that there are different internal syntax methods and over time, you will get to know which method works for your procedures of choice. However, another way to create an OUTPUT dataset is to use the ODS OUTPUT statement, in conjunction with ODS TRACE to create a dataset from one or more than one of the output objects created by your procedure of choice. The nice thing about using ODS OUTPUT is that the syntax of the ODS OUTPUT statement does NOT change based on each procedure, but the output object that you are using to create the dataset will change with each procedure. You can look up the output objects used by each procedure by using ODS TRACE and researching in the documentation. Here's a good paper on the use of ODS OUTPUT: 2.sas.com/6054OOBEu .
@michelef406
@michelef406 2 года назад
Using the code at 13:55 as a reference, how could i print out the name of the k-th student? I tried the following code, expecting the name of the first student as an output in the log but got simply *&(student1)* ` %let k=1; %put &(student&k); ` Thanks for the video and for any answer :)
@SASUsers
@SASUsers 2 года назад
Checking on this for you!
@SASUsers
@SASUsers 2 года назад
Thanks for your question! Unfortunately, we can't post code here in the RU-vid feedback area. This tutorial is derived from our Advanced Macro topics class, which assumes that you have an understanding of basic macro coding syntax. If you have taken our Macro Language 1 class 2.sas.com/6055Kb5u9 , you should review the section on resolving macro variables and you'll see that parentheses are not appropriate for the type of usage you show. A SAS Macro variable must be preceded by an & and because you put parentheses between the & and the student&k, no macro variable resolution is possible except for &k, which is why you get student1 in your parentheses in the log. In the Macro Language 1 class, we cover topics of indirect reference of macro variables that requires more than one & for the macro variable to resolve correctly. The code from time stamp 13:55 is shown again at time stamp 54:15-54:16 and you can see the correct %PUT statement to reference in the code that is being demonstrated. If you want to delay resolution of &student1, so that the &k can be resolved first, then you would need to use the macro variable reference &&student&k, as we show in the Macro Language 1 class. If you need a refresher on Macro topics, this user group paper on Macro basic concepts 2.sas.com/6057Kb5uc may be helpful. For questions like this, your best resource is our SAS Community Forums on SAS Programming 2.sas.com/6058Kb5uY, where you can post the code you've tried and ask questions about your code. Our SAS users and SAS employees monitor the Forums to help with questions like this.
@michelef406
@michelef406 2 года назад
@@SASUsers I can only be amazed by the depth and the quality of this answer. Thank you, the next time I decide to invest in my education I will remember this post :)
@SASUsers
@SASUsers 2 года назад
☺️
@srikanthreddy3454
@srikanthreddy3454 Год назад
Could you explain control flow(compile and execution)of proc step and also macros and proc sql
@SASUsers
@SASUsers Год назад
Srikanth, thank you for your inquiry! We are checking on this for you!
@SASUsers
@SASUsers Год назад
Srikanth, We detail how SAS compiles and executes code in the SAS Programming 2: Data Manipulation Techniques course. There is also a good paper SAS DATA Step - Compile, Execution, and the Program Data Vector. Charu does an excellent job explaining how PROC SQL processes in the Step-by-Step PROC SQL tutorial. We also offer SAS SQL 1: Essentials training. Check out Going Under the Hood: How Does the Macro Processor Really Work paper or SAS Macro Language 1: Essentials for more information on SAS macro processing.
@srikanthreddy3454
@srikanthreddy3454 Год назад
@@SASUsers is sas programming2 started ?,or else alredy is there can you please send me tha links
@SASUsers
@SASUsers Год назад
Yes, we do offer SAS Programming 1 as a free course. You can find a list of all of your e-learning courses here 2.sas.com/6050OyTxr
@srikanthreddy3454
@srikanthreddy3454 Год назад
%let a=one; Put &a; %put &a; What is the output of those statements
@SASUsers
@SASUsers Год назад
Thank you for your inquiry! We are checking on this for you!
@SASUsers
@SASUsers Год назад
Hi Srikanth, We are not able to post code and screen shots here in the RU-vid feedback area. It should be fairly easy for you to run the code to test it in a SAS session. The challenge with the code you posted is that the DATA step PUT statement cannot be used in open code and so if you submit this statement with the other 2, you would see an error message like "ERROR 180-322: Statement is not valid or it is used out of proper order." However, the %PUT statement should insert the value of &a into the log. So, if your %LET statement assigns the string one to the macro variable &a in the Global Symbol table the the %PUT should display the string one in the SAS log. For this type of question regarding SAS Macro processing, you may want to post in the SAS Community Forum for programming and macro questions, here: 2.sas.com/6058Ou2Tq . === ===
Далее
Highlights: Spanje - Gjeorgji
06:17
Просмотров 471 тыс.
SAS Tutorial | The Fundamentals of DATA Step Programming
1:36:47
SAS Tutorial | Simple Linear Regression in SAS
33:29
Просмотров 34 тыс.
SAS Tutorial | SAS SQL Methods and More
1:44:27
Просмотров 10 тыс.
Телефон в воде 🤯
0:28
Просмотров 1,2 млн