BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Ronein
Meteorite | Level 14

Hello

I want to build dataset from format(put the formats values from proc format into a data set).

This is the error I get

 

38 proc format cntlout= FormatDef(keep= Start rename=(Start = Category));
39 select $AgePratiVF.;
____________
22
200
ERROR 22-322: Syntax error, expecting one of the following: a name, $, @.

ERROR 200-322: The symbol is not recognized and will be ignored.

 

 

proc format;
value $AgeFmt
Other ='(a) Null'
'less 25'='(b) less 25'
'26-31'='(c) 26-31'
'32-42'='(d) 32-42'
'43-67'='(e) 43-67'
'more 67'='(f) more 67'
'All Other'='(g) All Other'
;
Run;

proc format cntlout= FormatDef(keep= Start rename=(Start = Category));
 select  $AgeFmt.;
run;

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

The documentation provides the answer.

 

No dot after the format name.

--
Paige Miller

View solution in original post

5 REPLIES 5
PaigeMiller
Diamond | Level 26

@Ronein wrote:

Hello

I want to build dataset from format(put the formats values from proc format into a data set).

This is the error I get

 

38 proc format cntlout= FormatDef(keep= Start rename=(Start = Category));
39 select $AgePratiVF.;
____________
22
200
ERROR 22-322: Syntax error, expecting one of the following: a name, $, @.

ERROR 200-322: The symbol is not recognized and will be ignored.

 


Please format your logs properly, so we can know what part of the code is actually underlined. You do this by pasting the log into the window that appears when you click on the </> icon. I am dismayed that after you have been in the SAS Communities for years now, you aren't doing this automatically.

--
Paige Miller
Ronein
Meteorite | Level 14
37         proc format cntlout= FormatDef(keep= Start rename=(Start = Category));
2                                                          The SAS System                             14:12 Monday, October 11, 2021

38          select  $AgeFmt.;
                    ________
                    22
                    200
ERROR 22-322: Syntax error, expecting one of the following: a name, $, @.  

ERROR 200-322: The symbol is not recognized and will be ignored.

NOTE: The previous statement has been deleted.
39         run;

NOTE: PROCEDURE FORMAT used (Total process time):
      real time           0.01 seconds
      user cpu time       0.00 seconds
      system cpu time     0.01 seconds
      memory              360.50k
      OS Memory           18592.00k
      Timestamp           10/11/2021 02:12:54 PM
      Step Count                        3  Switch Count  1
      Page Faults                       0
      Page Reclaims                     92
      Page Swaps                        0
      Voluntary Context Switches        41
      Involuntary Context Switches      0
      Block Input Operations            0
      Block Output Operations           0
      
NOTE: Compression was disabled for data set WORK.FORMATDEF because compression overhead would increase the size of the data set.
NOTE: No formats found that match SELECT statement.
NOTE: The data set WORK.FORMATDEF has 0 observations and 1 variables.
NOTE: The SAS System stopped processing this step because of errors.
40         
41         GOPTIONS NOACCESSIBLE;
42         %LET _CLIENTTASKLABEL=;
43         %LET _CLIENTPROCESSFLOWNAME=;
44         %LET _CLIENTPROJECTPATH=;
45         %LET _CLIENTPROJECTPATHHOST=;
46         %LET _CLIENTPROJECTNAME=;
47         %LET _SASPROGRAMFILE=;
48         %LET _SASPROGRAMFILEHOST=;
49         
50         ;*';*";*/;quit;run;
51         ODS _ALL_ CLOSE;
52         
53         
54         QUIT; RUN;
55         
PaigeMiller
Diamond | Level 26

The documentation provides the answer.

 

No dot after the format name.

--
Paige Miller
Ronein
Meteorite | Level 14
Thank you so much!!!! Th question is why a dot after format name will prevent getting the result ?
PaigeMiller
Diamond | Level 26

Since I didn't design or create the SAS language ... I can only guess.

 

In a DATA step, you have to indicate somehow that you are referring to a format and not a variable name, the dot tells SAS you mean a format and no dot tells SAS you mean a variable name. In PROC FORMAT, the SELECT statement only can refer to formats, not variable names, so not dot needed (and in fact a dot is wrong).

--
Paige Miller

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 5 replies
  • 784 views
  • 4 likes
  • 2 in conversation