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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1532 views
  • 3 likes
  • 4 in conversation