- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I am looking to create a macro that could show me statistics for new cases when I enter in the month and the country but it doesn't work.
data mylib_d3.covid_data;
run;
%MACRO proc_univariate_means_print(data,var1);
title ---Résumé statistiques_1---;
PROC UNIVARIATE data=&data;
CLASS &mois &pays
VAR &var1 ;
RUN;
title ---Résumé statistiques_2---;
PROC MEANS data=&data mean min max;
VAR &var1;
BY &mois &pays
RUN;
title --- Afficher les observations ---;
PROC PRINT data=&data;
VAR &var1;
RUN;
%MEND;
%LET mylist=nouveaux_cas mois pays
%proc_univariate_means_print(mylib_d3.covid_data, &mylist);
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@Feksan wrote:
I am looking to create a macro that could show me statistics for new cases when I enter in the month and the country but it doesn't work.
data mylib_d3.covid_data;
run;
....
If your program really does start with:
data mylib_d3.covid_data;
run;
then you will have overwritten mylib_d3.covid_data with an empty data set. I believe your log will say:
NOTE: The data set MYLIB_D3.COVID_DATA has 1 observations and 0 variables.
Even if the syntax of the rest of your code is correct, you will see no data reports.
More generally
but it doesn't work.
provides us with no information to diagnose or prescribe. Please show the log, tell us what you expected to see, and what you did see.
Help us help you.
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set
Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets
--------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Congratulations, with this step
data mylib_d3.covid_data;
run;
you have successfully destroyed your source data. The dataset will now contain 1 observation and 0 variables.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
In addition to destroying your data, this program contains basic syntax errors.
A BY statement must end with a semicolon.
A CLASS statement must end with a semicolon.
A good rule of thumb is to get your program working without macros first, and then try to convert it to a macro. It's too difficult for a beginner to debug if you have to figure out whether your error comes from SAS language or macro language.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@Astounding wrote:
A good rule of thumb is to get your program working without macros first, and then try to convert it to a macro. It's too difficult for a beginner to debug if you have to figure out whether your error comes from SAS language or macro language.
This is so important, I am going to repeat it.
"A good rule of thumb is to get your program working without macros first, and then try to convert it to a macro. It's too difficult for a beginner to debug if you have to figure out whether your error comes from SAS language or macro language."
If you can't get the code to work without macros and without macro variables, then it will never work when you use macros and macro variables.
Paige Miller