Presentation is loading. Please wait.

Presentation is loading. Please wait.

Knowing Understanding the Basics Writing your own code part 2 SAS Lab.

Similar presentations


Presentation on theme: "Knowing Understanding the Basics Writing your own code part 2 SAS Lab."— Presentation transcript:

1 Knowing Understanding the Basics Writing your own code part 2 SAS Lab

2 Review creating the dataset Open SAS Generate a dataset called ‘mygpa_name’: –In the sasuser library –Variables: Grade, GPA –4 Observations: Grades 9 through 12 –Make up the GPA scores –Grade = numerical data type

3 Variables If we were using Excel, think of these as the column headings Not static – i.e. weight You can create new ones based on variables that already exist – i.e. weight2 Assign values to variables –Var = Female –Values: 1=yes0=no

4 Practice Step 2 – create mygpa_name dataset copy Write another dataset with the (same name) ‘mygpa_name’ to a new library ‘Work’ –Data work.mygpa_name; Open dataset mygpa_name from sasuser library to get observations. –set sasuser.mygpa_name; Highlight and Run This Look in libraries to see that (working copy) datasets are there Why did we make this copy?

5 Create a new variable in an existing dataset Make a variable ‘GPAconvert’ that converts current GPA (from the gpa variable) to newGPA at a 0.204 rate Comment: –/*convert variable GPA from my school standard to new school standard*/ Syntax: –gpaconvert = 0.204*gpa; –Highlight and run. What happened? Why?

6 Procedures (Descriptive Stats) cont… NOTE: Images on these slides are different than your results! What is PROC CONTENTS for? –proc contents data = work.mygpa_name; run;

7 Procedures (Descriptive Statistics) What is PROC FREQ for? –proc freq data = work.mygpa_name; table group; run;

8 Procedures (Descriptive Stats) cont… What is PROC MEANS for? –proc means data = work.mygpa_name; var grade gpaconvert; run;

9 Practice Step 3 – do it again! Generate a dataset ‘CustomerList’ with the following specs: Variables: Age, PurQuantity, ItemNum, Gender, Member, NumYears ItemNum contains 3 products with associated value assigned (you make it up, but keep it numerical) Assign values to Var Gender: –Male=0, Female=1, Undetermined=2 Member is a boolean (yes/no) datatype. NumYears is where we store the number of years this customer has been a member of our loyalty programs. Create 3 Observations Put into the sasuser library Highlight and run. Check log and libraries to see that you successfully completed the task

10 CustomerList continued… Create a working copy of CustomerList in the Work Library. Make a new variable ‘NumMos’ that converts the current number of years of loyalty from those customers who are members to the number of months.

11 CustomerList continued… Generate Output (including an HTML file) for the 1.contents of the data. 2.Means of the data based on the variables of _____ and _____. 3.Frequency of the data based on the _____. 4.FILL IN THE BLANKS, highlight and RUN. (what makes most sense?)

12 Knowing Writing your own Code - part 2


Download ppt "Knowing Understanding the Basics Writing your own code part 2 SAS Lab."

Similar presentations


Ads by Google