For a school project, one of the things I am being graded on is the correct number of observations appearing when I run proc contents for my code. Some of it works, and some of it doesn't. Here is an example of code that doesn't show the observations:
LIBNAME Check XLSX "&CourseRoot/CDPHE Study/Data/1_Source/Employment.xlsx"; LIBNAME Check CLEAR; LIBNAME CoImpt XLSX "&CourseRoot/CDPHE Study/Data/1_Source/Employment.xlsx"; PROC PRINT DATA = CoImpt.Employment; LABEL; PROC CONTENTS DATA=CoImpt.Employment; RUN;
How do I get the observation count to appear in results when proc contents are run? I know it is not a SAS dataset, but I'm not familiar with the code to get observation counts from other datasets to read in (I cannot change the data for the purposes of the assignment). Thank you for any assistance.
/* Create SAS data set */
data want;
set CoImpt.Employment;
run;
/* Run PROC CONTENTS on SAS data set */
proc contents data=want;
run;
CoImpt.Employment is not a SAS data set, it is an Excel file.
PROC CONTENTS will show the number of observations if it is a SAS data set.
So is the solution to this to save the .xlsx file as a SAS dataset within SAS and ask in the code for SAS to read in the data from the new .sas data set? If so, how do I write code for this?
/* Create SAS data set */
data want;
set CoImpt.Employment;
run;
/* Run PROC CONTENTS on SAS data set */
proc contents data=want;
run;
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
For SAS newbies, this video is a great way to get started. James Harroun walks through the process using SAS Studio for SAS OnDemand for Academics, but the same steps apply to any analytics project.
Find more tutorials on the SAS Users YouTube channel.