0

I am trying to learn SAS coding through WPS Workbench. I am confused about how if I have datasets e.g. height of humans, already, how do I refer or use these datasets in my code so I can begin to analyse it? Right now they are in separate windows (editor and dataset SAS7BDAT file). Sorry if this sounds confusing. I am quite confused.

  • What is the NAME of the dataset you want to reference? What do you want to DO with the dataset? Do you want to use it as the input to some procedure? Like PROC MEANS? – Tom Jan 11 '22 at 23:04
  • By name do you mean file name? Or something else? And yes that is what I want to do, input and then things like PROC MEANS – Mattatcomputer Jan 11 '22 at 23:26
  • Why use WPS? SAS Academy on Demand is free and cloud based and the programming courses are also free from SAS directly. – Reeza Jan 13 '22 at 02:26
  • SAS On Demand: https://www.sas.com/en_us/software/on-demand-for-academics.html Training: https://www.sas.com/en_us/training/offers/free-training.html – Reeza Jan 13 '22 at 02:28
  • Thanks Reeza this is really helpful. I didn't know Sas offered free courses and I'll definitely check it out. I have to use WPS in this case as it's for a job interview where they use WPS. – Mattatcomputer Jan 13 '22 at 09:45

1 Answers1

0

Create a libref that points to the directory that contains the SAS7BDAT file(s). You can use any valid 8 character or less SAS name for your libref.

Then just reference the dataset using a two level dataset reference. Before the period is the libref you defined in the LIBNAME statement and after the period is the dataset (or member) name. That name should match the base name of the file with the SAS7BDAT extension.

So to run PROC MEANS on a file named c:\myfiles\mydata.sas7bdat you could use code like:

libname mydat 'c:\myfiles';
proc means data=mydat.mydata;
run;

This syntax works in real SAS and I assume that WPS will also support such simple code.

Tom
  • 47,574
  • 2
  • 16
  • 29
  • Thank you Tom for your explanation. I am not at home right now so I can't test this but I was just wondering if I can refer to variables within the file I have done a libref on? E.g. if the dataset file contained a column for years and the observations were an assortment of years from 1995-2005 could I refer to this column in my code and isolate just observations with years 2000 and later? – Mattatcomputer Jan 13 '22 at 09:43
  • If your dataset had a VARIABLE named YEAR with numeric values like 1,995 and 2,005 to represent years then you could add a where statement to your PROC step to limit the observations that will be used by the proc. `where year between 1995 and 2005;` – Tom Jan 13 '22 at 12:20