BookmarkSubscribeRSS Feed
mageshb
Calcite | Level 5

Hi,

 

ERROR 22-322: Syntax error, expecting one of the following: a name, _ALL_, _CHARACTER_, _CHAR_, _NUMERIC_.
 
data new;
set '/folders/myshortcuts/myfolder/aprsales.sas7bdat';
format date9.;
run;
2 REPLIES 2
Cynthia_sas
SAS Super FREQ

Hi:

  I would expect you are getting that error message on the FORMAT statement, because the statement is incorrect. Is this what you are seeing?

bad_fmt_stmt.png

 

Typically, in a format statement, you have:

format variable formatname.; /* for numeric variables */

or

format variable $fmtname.; /* for character variables */

 

You are missing the name of the variable that you want to format in the statement.

 

cynthia

 

ps, also consider you investigate the use of the LIBNAME statement rather than the fully qualified path and operating system name of the SAS dataset...but that is just a suggestion.

Reeza
Super User

You should do this:

 

1. Fix your SAS UE setup - you need to create a folder called myfolders not myfolder - it's why you possibly had issues with getting it set up. Place the file in that folder. You can continue to use your current setup but it's probably easier in the long run to set it up correctly. 

2. Set up a library to the location where you save your SAS datasets. You can point directly to the file like you've done but you'll almost never seen that done anywhere. 

3. As indicated your FORMAT statement is incorrect.

 

The code snippet below may help. FYI - you do not need to format the date to filter it first to get only the dates of interest. As long as the variable IS a SAS date, so numeric with a date format (date9, yymmdd8, monyy7.) then you can filter it as desired.

 

libname myFiles '/folders/myshortcuts/myfolder/';

data new;
    set myFiles.aprsales;

    format  MY_DATE_VARIABLE date9.;

*Filter for less than Jan dates;
WHERE MY_DATE_VARIABLE <= "01Jan2016"d; run;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 990 views
  • 1 like
  • 3 in conversation