Save as Integers using sas studio

Reply
Contributor
Posts: 27

Save as Integers using sas studio

Hello, 

 

I am having issue of how to save Daily Max-8 hour Ozone Concentration, DAILY_AQI_VALUE,DAILY_OBS_COUNT, and PERCENT_COMPLETE as Integers? I have paste my sample of data below for you to try out. Any help is greatly appreciated.

 

I tried doing with Data steps: 

 

DATA WORK.MYCSVIntegers;
SET WORK.MYCSV1;
Daily Max 8-hour Ozone Concentration= Int(Daily Max 8-hour Ozone Concentration);
RUN;

 

 

So far, no luck. The errors are:

1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
55
56 DATA WORK.MYCSVIntegers;
57 SET WORK.MYCSV1;
58 Daily Max 8-hour Ozone Concentration= Int(Daily Max 8-hour Ozone Concentration);
_____
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
 
59 RUN;
 
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.MYCSVINTEGERS may be incomplete. When this step was stopped there were 0 observations and 18 variables.
WARNING: Data set WORK.MYCSVINTEGERS was not replaced because this step was stopped.

========================================================================================================The DATA is shown below. Please try out and let me know. There are headers start from Date and SITE_LONGITUDE.  

 

Date,AQS_SITE_ID,POC,Daily Max 8-hour Ozone Concentration,UNITS,DAILY_AQI_VALUE,DAILY_OBS_COUNT,PERCENT_COMPLETE,AQS_PARAMETER_CODE,AQS_PARAMETER_DESC,CBSA_CODE,CBSA_NAME,STATE_CODE,STATE,COUNTY_CODE,COUNTY,SITE_LATITUDE,SITE_LONGITUDE
1/1/2015,340010006,1,0.036,ppm,33,24,100,44201,Ozone,12100,"Atlantic City-Hammonton, NJ",34,New Jersey,1,Atlantic,39.464872,-74.448736
1/2/2015,340010006,1,0.03,ppm,28,24,100,44201,Ozone,12100,"Atlantic City-Hammonton, NJ",34,New Jersey,1,Atlantic,39.464872,-74.448736
1/3/2015,340010006,1,0.027,ppm,25,24,100,44201,Ozone,12100,"Atlantic City-Hammonton, NJ",34,New Jersey,1,Atlantic,39.464872,-74.448736
1/4/2015,340010006,1,0.022,ppm,20,24,100,44201,Ozone,12100,"Atlantic City-Hammonton, NJ",34,New Jersey,1,Atlantic,39.464872,-74.448736
1/5/2015,340010006,1,0.033,ppm,31,24,100,44201,Ozone,12100,"Atlantic City-Hammonton, NJ",34,New Jersey,1,Atlantic,39.464872,-74.448736
1/6/2015,340010006,1,0.031,ppm,29,24,100,44201,Ozone,12100,"Atlantic City-Hammonton, NJ",34,New Jersey,1,Atlantic,39.464872,-74.448736
1/7/2015,340010006,1,0.032,ppm,30,24,100,44201,Ozone,12100,"Atlantic City-Hammonton, NJ",34,New Jersey,1,Atlantic,39.464872,-74.448736
1/8/2015,340010006,1,0.031,ppm,29,24,100,44201,Ozone,12100,"Atlantic City-Hammonton, NJ",34,New Jersey,1,Atlantic,39.464872,-74.448736
1/9/2015,340010006,1,0.032,ppm,30,24,100,44201,Ozone,12100,"Atlantic City-Hammonton, NJ",34,New Jersey,1,Atlantic,39.464872,-74.448736
1/10/2015,340010006,1,0.03,ppm,28,24,100,44201,Ozone,12100,"Atlantic City-Hammonton, NJ",34,New Jersey,1,Atlantic,39.464872,-74.448736
1/11/2015,340010006,1,0.034,ppm,31,24,100,44201,Ozone,12100,"Atlantic City-Hammonton, NJ",34,New Jersey,1,Atlantic,39.464872,-74.448736
1/12/2015,340010006,1,0.023,ppm,21,24,100,44201,Ozone,12100,"Atlantic City-Hammonton, NJ",34,New Jersey,1,Atlantic,39.464872,-74.448736
1/13/2015,340010006,1,0.028,ppm,26,24,100,44201,Ozone,12100,"Atlantic City-Hammonton, NJ",34,New Jersey,1,Atlantic,39.464872,-74.448736
1/14/2015,340010006,1,0.031,ppm,29,24,100,44201,Ozone,12100,"Atlantic City-Hammonton, NJ",34,New Jersey,1,Atlantic,39.464872,-74.448736
1/15/2015,340010006,1,0.02,ppm,19,24,100,44201,Ozone,12100,"Atlantic City-Hammonton, NJ",34,New Jersey,1,Atlantic,39.464872,-74.448736

Grand Advisor
Posts: 17,420

Re: Save as Integers using sas studio

Your variable names are too long and have characters not allowed. 

 

Variable names include only:

numbers

letters

underscore

- no spaces

- cannot start with a number

- less than 32 chars.

 

I'm not sure what your actual variable name is, but you can find it out using a proc contents. You'll see the variable names and labels. Names are what you use in your programs. Labels can be used in reporting. 

 

proc contents data=mycsv1;
run;

Once you've determined your variable name, try the input function again.

 

var_numeric = input(var_character, 8.);
Contributor
Posts: 27

Re: Save as Integers using sas studio

Hello Reeza,

Thank you. It worked. I used a 

var_numeric = input(var_character, 8.);

and it saved as integers. Thanks. And just a note, I had issues with date and had to use  MMDDYY12. , instead 10.  why did it work with 12. ? Can you explain, please? Thank you.

 

DATA work.mycsvdate;
infile "/home/pandyat0/sasuser.v94/Pandya_Ozone.csv" FIRSTOBS=2;
input mydate MMDDYY12.;
RUN;
Contributor
Posts: 27

Re: Save as Integers using sas studio

DATA WORK.MYCSVIntegers; 
SET WORK.MYCSV1;
ozoneconc= Int(Ozoneconc);
RUN;

I had to change my variable name and make it shorter (about 13 characters, no space and number--what I thought ). I then ran command above to make intergers  but input was working as it was taking all numbers a whole integers (what I thought my prof asked for). I had to use 'int' and it had worked. I just opened the file and check. Thanks for clarifying and following up with me. 

 

DATA WORK.MYCSVCharacters; 
SET WORK.MYCSV1;
ozoneconc = input(ozoneconc, 8.);
run;

 The code above gave me all 0 and some ". " as it turned all integers like these. I had to check and make sure with my prof, he said input is useful but then he said use int instead. 

 

I appreciate your help and response. Thank you.

 

Ask a Question
Discussion stats
  • 3 replies
  • 289 views
  • 1 like
  • 2 in conversation