Thank you guys so much for helping the other day.
I am here again.
1. How do I prevent the 'character values have been converted to numeric values at the place by: (Line):(Column) from appearing the log message.
I am trying to use a combined dataset to create a temporary subset that contains only female participants who live in the urban area (Urban=1).
what instructions to I give SAS to prevent the conversion message.
I have attached a picture of the log message with the numeric conversion that I do not want.
DM "out; clear; log; clear;";
DATA B1;
INFORMAT DOB mmddyy10.;
INFILE "C:\Users\iyink\Downloads\fa22_demog.txt" DLM=',' DSD FIRSTOBS=2;
INPUT ID Gender $ AgeOld Married Employed Urban SBP DOB;
FORMAT DOB mmddyy10.;
RUN;
PROC PRINT DATA=B1;
RUN;
*/ THERE ARE 8 variables and 200 Observations in B1 */;
LIBNAME iyin634 "C:\Users\iyink\Downloads";
RUN;
PROC PRINT DATA=iyin634.Fa22_others;
RUN;
PROC SORT DATA=B1 NODUP; BY ID; RUN;
PROC SORT DATA=iyin634.Fa22_others NODUP; BY ID; RUN;
DATA B2;
MERGE B1(IN=a) iyin634.Fa22_others(IN=b);
BY ID;
IF a=1 OR b=1 THEN OUTPUT B2;
RUN;
PROC PRINT DATA=B2;
RUN;
*/ THERE ARE 14 variables and 200 observations in B2 */;
DATA B2_f;
SET B2;
IF Gender= 'Female' THEN OUTPUT;
RUN;
DATA B2_f1;
SET B2_f;
IF Urban= '1' THEN OUTPUT;
RUN; */ this portion is showing me "character values have been converted to numberic values...." and this shouldn't be. So how do I pick observations for the female and Urban=1 variables to output into B2_f. I ran them differently, is that what I should have done?*/ ;
*/ THERE ARE 14 variables and 112 observations in B2_F1 */;
PROC MEANS DATA=B2 n mean std;
CLASS AgeOld;
VAR cho cr hdl_c ldl_c;
RUN; */ then this part output looked like 1 and 0 but I want it to have Ageold as 'Old' for where the out put shows '1' and Young where the MEANS procedure shows '0' */;
PROC FREQ DATA=B2;
TABLE AgeOld*GoodLipid;
RUN;
*/ proportion of those with GoodLipid status
For the Old Population = 26/37 (70.27%)
For the Young Population = 130/155 (83.87%)
For the Overall Population = 156/192 (81.25%) */;
2. How do I make the variable name: AgeOld values appear as words like 'Old' and 'Young' and not as '1' and '0' (original values in data set) in the output for the MEANS procedure, when I use the PROC MEANS step.
I have attached a picture of what I am trying to create and a picture of my output error.
3. How to permanently save a combined data set to a flash drive how do I that? Is it like the basic way or there is a code I have to use?
ORDER OF PHOTOS:
1 - the instructions for what my work should look like
2. my error output for the AgeOld variable.
3. my error log message with the numeric conversion.
Thank you. I love a response today. This work is due later today.
thanks 🙂
1. How do I prevent the 'character values have been converted to numeric values at the place by: (Line):(Column) from appearing the log message.
You read the variable Urban in the first data step as numeric.
You compare
Urban = '1'
The '1' is a character value. To actually compare to the defined numeric variable Urban SAS tries to help by converting to numeric to see if the comparison can be done.
Fix: don't compare to a character value
Urban = 1
or read the variable as character.
2. How do I make the variable name: AgeOld values appear as words like 'Old' and 'Young' and not as '1' and '0' (original values in data set) in the output for the MEANS procedure, when I use the PROC MEANS step.
Value appearance or display is the role of the variable FORMAT.
You make a custom format to associate the value with the desired text. Note that you are again displaying a numeric variable AgeOld which has values of 1 or 0 with quotes marks which would be character variable. Here a one way to create such a format and then associate the format in use in a procedure.
Proc Format; value AgeOld 1='Old' 0='Young' ; proc means; var ageold ; format ageold ageold. ; run;
Caution: This is a temporary format an will only exist for the duration of the current session. You will need to rerun the Proc Format code to make it available in other sessions.
3. How to permanently save a combined data set to a flash drive how do I that? Is it like the basic way or there is a code I have to use?
With SAS code you could assign a LIBNAME to the drive and use SAS tools to copy the set.
When the flashdrive is active in the computer it should have a drive letter assigned. Suppose after you insert it Windows explorer shows it as Drive F.
In your code include:
libname flash "F:\"; proc copy in=work /* of the name of the library where the "combined" set resides*/ out=flash; select combined; /* of the name of the data set you want to copy from the work library*/ run;
If your flash drives have folders add them like "F:\folder1\subfolder";
Or without involving SAS at all go to the location of the library using Windows Explorer or other file management program, copy the "combined.sas7bdat" using the Windows Explorer copy and paste or drag and drop.
Note that your WORK library on a Windows system is likely to look something like this:
C:\Users\XXXXX\AppData\Local\Temp\SAS Temporary Files\_TD9028_DESKTOP-C36D7SF_
but that last folder name changes every session
1. How do I prevent the 'character values have been converted to numeric values at the place by: (Line):(Column) from appearing the log message.
You read the variable Urban in the first data step as numeric.
You compare
Urban = '1'
The '1' is a character value. To actually compare to the defined numeric variable Urban SAS tries to help by converting to numeric to see if the comparison can be done.
Fix: don't compare to a character value
Urban = 1
or read the variable as character.
2. How do I make the variable name: AgeOld values appear as words like 'Old' and 'Young' and not as '1' and '0' (original values in data set) in the output for the MEANS procedure, when I use the PROC MEANS step.
Value appearance or display is the role of the variable FORMAT.
You make a custom format to associate the value with the desired text. Note that you are again displaying a numeric variable AgeOld which has values of 1 or 0 with quotes marks which would be character variable. Here a one way to create such a format and then associate the format in use in a procedure.
Proc Format; value AgeOld 1='Old' 0='Young' ; proc means; var ageold ; format ageold ageold. ; run;
Caution: This is a temporary format an will only exist for the duration of the current session. You will need to rerun the Proc Format code to make it available in other sessions.
3. How to permanently save a combined data set to a flash drive how do I that? Is it like the basic way or there is a code I have to use?
With SAS code you could assign a LIBNAME to the drive and use SAS tools to copy the set.
When the flashdrive is active in the computer it should have a drive letter assigned. Suppose after you insert it Windows explorer shows it as Drive F.
In your code include:
libname flash "F:\"; proc copy in=work /* of the name of the library where the "combined" set resides*/ out=flash; select combined; /* of the name of the data set you want to copy from the work library*/ run;
If your flash drives have folders add them like "F:\folder1\subfolder";
Or without involving SAS at all go to the location of the library using Windows Explorer or other file management program, copy the "combined.sas7bdat" using the Windows Explorer copy and paste or drag and drop.
Note that your WORK library on a Windows system is likely to look something like this:
C:\Users\XXXXX\AppData\Local\Temp\SAS Temporary Files\_TD9028_DESKTOP-C36D7SF_
but that last folder name changes every session
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 16. Read more here about why you should contribute and what is in it for you!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.