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

Hi,

 

This is copied directly from Learning SAS by Example. My understanding is that when there is an exact match, the value should be 0, and that it increases the further away a match is. However, the results I am getting show a value of 137 for all the inputs except for Alfred, which is 166. Also, the lock says that the variable Friedman is unitiialized, whatever that means?

 

Any suggestions on why I am getting values of 137, and also what a variable that is unitialized means?

Thanks!

 

Here is the code:

------------------------

 

Data fuzzy ;

input Name $20. ;

Value = spedis(Name,‘Friedman’) ;

datalines ;

Friedman

Freedman

Xriedman

Freidman

Alfred

FRIEDMAN

;

 

Here are the results

-------------------------

 

Name       Value  Friedman

Friedman 137     .

Freedman 137    .

Xriedman 137     .

Freidman 137     .

Alfred 166           .

FRIEDMAN 137   .

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

The quotes you have around "Friedman" within the function are not true quotes ... they are some similar character.  Try deleting them, and re-typing the quotes, then re-run.

View solution in original post

6 REPLIES 6
Astounding
PROC Star

The quotes you have around "Friedman" within the function are not true quotes ... they are some similar character.  Try deleting them, and re-typing the quotes, then re-run.

ballardw
Super User

The code you posted will not run.

This line

Value = spedis(Name,‘Friedman’) ;

has "smart quotes", the curly version instead of a simple '

 

After correcting that error when I run your code I get

Name Value
Friedman 0
Freedman 12
Xriedman 25
Freidman 6
Alfred 100
FRIEDMAN 87
So there may be something else going on.
ManitobaMoose
Quartz | Level 8

Hi,

 

Thanks for looking at this. I did remove the quotes, but I am still getting the error with the same results. Below is the Text, and then the log:

 

CODE:

Data fuzzy ;

input Name $20. ;

Value = spedis(Name,Friedman) ;

datalines ;

Friedman

Freedman

Xriedman

Freidman

Alfred

FRIEDMAN

;

 

 

LOG:

62 Data fuzzy ;
63 input Name $20. ;
64 Value = spedis(Name,Friedman) ;
65 datalines ;
 
NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).
64:22
NOTE: Variable Friedman is uninitialized.
NOTE: The data set WORK.FUZZY has 6 observations and 3 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
ManitobaMoose
Quartz | Level 8

OK. Now I got it to work. What are smart quotes vs simple quotes? Thanks!

ballardw
Super User

@ManitobaMoose wrote:

OK. Now I got it to work. What are smart quotes vs simple quotes? Thanks!


Smart quotes are for word processing to make a start/end pair of smbols around the words look pretty like in typeset books.

The simple quote, in this case, is the programming language text identifier a value between ' '  or "  " is treated as text value

(except for the things like date and name literals which have an ending character pair like 'd 'dt "n and such).

 

Programming languages are build with limits, spell things right or get an error, use the correct symbol or get an error, end the statement correctly or get an error....

 

Follow the syntax rules to get the desired results.

Reeza
Super User

Use the code from the provided files or type it out. You're likely getting these errors by copying the code from a PDF file or EPUB file I assume...assuming a legal version. I've seen illegal versions in Doc files but I'm assuming you're using a legal version.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 6 replies
  • 1277 views
  • 0 likes
  • 4 in conversation