BookmarkSubscribeRSS Feed
Mathis1
Quartz | Level 8

Hi, I have to add a numeric variable to an existing dataset. I then used this code :

 


data WANT;
set HAVE;
put INDIC_2009 8.;
format INDIC_2009 comma8.2;
datalines;
38,64
.
.
.
-18,36
0,36
0,36
-88,96
0,12
-88,96
-53,66
0,2
-21,344
2
3
-88,96
-88,96
-18,36
-88,96
0,12
-53,66
0,12
0,12
0,36
0,36
0,36
-107,32
0,6
-106,72
;
run;

 

But it does not work. I only get "."  

 

 

Any idea ?

 

Thank you !

3 REPLIES 3
PaigeMiller
Diamond | Level 26

Look at the data set HAVE. Is the variable INDIC_2009 character or numeric? Are there errors or warnings in the LOG?

--
Paige Miller
jimbarbour
Meteorite | Level 14

I added an INFILE and an INPUT statement to your Data step, and it seems to be working.  See code, below, and see results, below the code.  I also changed the commas to decimal points, but I am based in the US, so a comma may be valid where you are.  

 

data WANT;
	set HAVE;
*	put INDIC_2009 8.;
	format INDIC_2009 comma8.2;
	INFILE	Datalines;
	INPUT	INDIC_2009;

Jim

 

Results:

Infile_Input_Results_2020-09-04_09-58-37.jpg

Reeza
Super User
I think you actually want the Commax informat? Because those comma's look like decimals to me...
https://documentation.sas.com/?docsetId=leforinforref&docsetTarget=n0aggga4tdr094n14ecw1smkhva7.htm&...

Change INFILE to INPUT as indicated by @PaigeMiller and you should be good from there.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 835 views
  • 3 likes
  • 4 in conversation