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

Dear all,

 

I imported an SPSS file using PROC IMPORT. The import ran smoothly.

One of the variables in the dataset was a filter variable in SPSS, and SAS kept its name: FILTER_$.

This variables has values Selected or Non Selected, and SAS tells me its TYPE is numeric (which is strange) and that its FORMAT is FILTER_A.

See attached PDF with two pages that contain snapshots of the SAS file and the variable info.

SAS does not recognize the variable name FORMAT_$ when i try to use it, and if I try to RENAME it, I get the error message detailed in page 3 of the attached PDF file.

 

Any idea of why it doest not recognize the variable name?  My guess is that it has to do with the fact that it is considered a filter variable by SAS (hence the format that it gives it), but when I do a PROC FREQ without specifying any variable, it gives me a table for that variable, too!  I simply cannot use its name - it's like Voldemort! 

 

Any suggestion?

 

Eman

1 ACCEPTED SOLUTION

Accepted Solutions
s_lassen
Meteorite | Level 14

If the variable name contains "illegal" characters, or begins with a number, you can refer to it in programs like this:

'FILTER_$'n

- just put the name in quotes and put an "n" afterwards.

 

I am not familiar with SPSS output and filter variables, but it looks like it is a logical value, which is 1 or 0 in SAS. So my guess is that the format shows "Selected" when the value is 1, and "Not selected" when it is 0.

 

You can see the numeric values by using another format in e.g. PROC PRINT:

proc print data=<SPSS_Import>(obs=20);
  format 'FILTER_$'n best32.;
run;

View solution in original post

3 REPLIES 3
s_lassen
Meteorite | Level 14

If the variable name contains "illegal" characters, or begins with a number, you can refer to it in programs like this:

'FILTER_$'n

- just put the name in quotes and put an "n" afterwards.

 

I am not familiar with SPSS output and filter variables, but it looks like it is a logical value, which is 1 or 0 in SAS. So my guess is that the format shows "Selected" when the value is 1, and "Not selected" when it is 0.

 

You can see the numeric values by using another format in e.g. PROC PRINT:

proc print data=<SPSS_Import>(obs=20);
  format 'FILTER_$'n best32.;
run;
emaneman
Pyrite | Level 9

Thank you.

 

I renamed the variable by adding:

 

rename 'FILTER_$'n=filter;

and now the new variable called simply filter, which can be then used.

 

 

 

'FILTER_$'n

 

Kurt_Bremser
Super User

To use such variable names in SAS, you need to have

options validvarname=any;

set and use a "name literal":

'FILTER_$'n

 Your variable is most probably a boolean type in SPSS, with a proper format attached to translate the two possible numeric values (1 or 0) to the strings you see. AFAIK, the SPSS import should create that format, but you may have to set the FMTSEARCH option.

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
  • 3 replies
  • 576 views
  • 0 likes
  • 3 in conversation