170 data work.condo_ranch;
171 infile 'C:\mysaslib\houses' dsd;
172 input style $ @;
173 if style = 'CONDO' or style = 'RANCH' then
174 input sqfeet bedrooms baths street $ price : dollar10.;
NOTE: The infile 'C:\mysaslib\houses' is:
RECFM=V,LRECL=256,File Size (bytes)=283,
NOTE: 7 records were read from the infile 'C:\mysaslib\houses'.
The minimum record length was 34.
The maximum record length was 42.
NOTE: The data set WORK.CONDO_RANCH has 7 observations and 6 variables.
NOTE: DATA statement used (Total process time):
real time 0.34 seconds
cpu time 0.01 seconds
The statement infile 'file-specification' dsd; is using the dsd option. This DSD (Delimiter-Sensitive Data) option for the INFILE statement does three things for you. First, it ignores delimiters in data values enclosed in quotation marks. Second, it does not read quotation marks as part of the data value. Third, it treats two delimiters in a row as a missing value. The DSD option assumes that the delimiter is a comma.
The statement input style $ @; is using the @ keyword. This INPUT statement with an 'at' sign (@) is referred to as a trailing at. This tells SAS to hold that line of raw data. While the trailing @ holds that line, you can test the observation with an IF statement to see if it is one you want to keep. If it is, then you can read data for the remaining variables with a second INPUT statement.
Here after reading the value for style, the statement if style = 'CONDO' or style ='RANCH' then will only read additional input values if style is 'CONDO' and 'RANCH'; if style is anything other than these two values, it will not read additional input. So in the output dataset we have only values for variables sqfeet, bedrooms, baths, street, and price corresponding to those observations where style has values of 'CONDO' or 'RANCH' only.
The one and only FREE resource for general SAS online training as well as study guides for the SAS Base Certification. My goal is to create the SAS Certification prep guide that I never found but always wanted. This should also be a place to come if you are new to the language but are simply looking for online SAS training.