I'm using SAS Studio University Edition. The main reason I have it is to go through the SAS certification prep guide for Base programming. I have my shared folders for the Virtual machine at D:\Data\SAS\SASUniversityEdition\myfolder. I was able to get the files used for the prep guide and I see them in the folders tab under My Folders/sasuser.v94. I'm trying to do the first example which is to load the admit.dat data and then print it out. I am able to read it in, but the working data says it has 0 observations and 9 variables. Here is the code I use to bring in the data.
filename admit '/folders/myfolders/sasuser.v94/admit.dat';
data admit2;
infile admit;
input ID 1-4 Name $ 6-25 RestHR 27-29 MaxHR 31-33
RecHR 35-37 TimeMin 39-40 TimeSec 42-43
Tolerance $ 45;
if tolerance='D';
TotalTime=(timemin*60)+timesec;
run;
proc print data=admit2;
run;
And here is the Log showing the issue:
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
42 ;
43 filename admit '/folders/myfolders/sasuser.v94/admit.dat';
44 data admit2;
45 infile admit;
46 input ID 1-4 Name $ 6-25 RestHR 27-29 MaxHR 31-33
47 RecHR 35-37 TimeMin 39-40 TimeSec 42-43
48 Tolerance $ 45;
49 if tolerance='D';
50 TotalTime=(timemin*60)+timesec;
51 run;
NOTE: The infile ADMIT is:
Filename=/folders/myfolders/sasuser.v94/admit.dat,
Owner Name=sasdemo,Group Name=sas,
Access Permission=-rw-rw-r--,
Last Modified=05Oct2014:22:13:58,
File Size (bytes)=1701
NOTE: 21 records were read from the infile ADMIT.
The minimum record length was 80.
The maximum record length was 80.
NOTE: The data set WORK.ADMIT2 has 0 observations and 9 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.03 seconds
52 proc print data=admit2;
53 run;
NOTE: No observations in data set WORK.ADMIT2.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.04 seconds
cpu time 0.01 seconds
54
55
56
57 ;
58 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
68 ;
Any help would be appreciated...
I would start by looking in the text file at the value of Tolerance. Comment out the line "If Tolerance = 'D'; and examine the values you actually read for Tolerance. Since you assigned a length of 45 I'm willing to be that at least some if not all of the values of tolerance are 1) longer than 'D' and 2) possibly not uppercase, i.e. 'd'.
I would start by looking in the text file at the value of Tolerance. Comment out the line "If Tolerance = 'D'; and examine the values you actually read for Tolerance. Since you assigned a length of 45 I'm willing to be that at least some if not all of the values of tolerance are 1) longer than 'D' and 2) possibly not uppercase, i.e. 'd'.
Yep, when I removed that line it worked. Thank you.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.