BookmarkSubscribeRSS Feed
pallab
Calcite | Level 5

Need urgent help to complete the assignment please:

NOTE:Files are attached

 

1)
a) Import HTWT data set to extract 10 observations starting from fifth observation using SAS macros.
b) Write a macro to compare two numeric values.
(Hint: a) Use proc print. b) Use %if %then %do statement.)


2) Let’s say you have "Revenue" information for different years from 2005 to 2009 with variable revenue. Write SAS macro which will apply means and univariate procedure on each year for revenue variable.
(Hint: Define a macro variable to specify the procedure “name”.)


3) The data set "Macro definition.txt" has two SAS macros definition, import them and apply on HTWT data set.
(Hint: Use %INCLUDE.)


4) Save the macros permanently defined so far and list all the macros.
(Hint: Use options mstored sasmstore then run proc catalog.)

2 REPLIES 2
pallab
Calcite | Level 5

Required help to convert the below SAS codes into macros.


a) proc gchart data=HTWT; vbar gender/sumvar=weight; Title "Average weight by Gender";
run;
b) proc plot data=HTWT; Title "Scatter plot"; plot &height*&weight;
run;
(Hint: Define two different macros.) 

RW9
Diamond | Level 26 RW9
Diamond | Level 26

So you have an assignment to do, and you are asking us to do it for you.  I don't believe this is the place to be hiring contract workers.  As such I would suggest you progress with the assignment as you can and come back with any specific questions you might have.

As a starting point, and an easy way to start with macro is:

1) Learn Base SAS - this is the programming language, it is what is compiled and run, it should be used for data manipulation

2) Write your code first off solely in Base SAS, no macro

3) Once you have a working program, identify repeating parts, or parts that could be parameterised

4) Modify the code to use macros where, and only where, they add value.  Writing macro purely for the purpose of writing macro will result in garbage code which falls over every run

 

When you have done the above many times you will see a lot of it up front, but that is when you should be using software development lifecycle methodology anyways, i.e. documenting everything, inputs, outputs, processes, links etc. So writing the code at that point becomes moot because it is already documented and written down.

 

A final note, you have the terms in that text, a simple google on "SAS <xyx>" replace xyz with term, will yield the manual and examples.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 509 views
  • 2 likes
  • 2 in conversation