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

Kindly see the error in log file and suggest the solution

 

Tejaswini3_0-1645623893643.png

 

Tom
Super User Tom
Super User

Please post text as text and not as photographs!

 

Your photograph does not show any attempt to define the formats.  Did the dataset you posted the photograph of before work as a CNTLIN= dataset in PROC FORMAT step?  Did the log show it creating any of the formats named in the errors message in your photograph of the data step?

 

Why are you referencing variables in the KEEP and FORMAT statements that do not exist?

Tejaswini3
Obsidian | Level 7

Log file

11 libname sasfile 'D:\SAS\Project\Project 3- Interating Data
11 ! for PKAnalysis\Project 3- Interating Data for
11 ! PKAnalysis\Work\04utility';
NOTE: Libref SASFILE was successfully assigned as follows:
Engine: V9
Physical Name: D:\SAS\Project\Project 3- Interating Data
for PKAnalysis\Project 3- Interating Data for
PKAnalysis\Work\04utility
12 proc copy inlib=xptfile outlib=sasfile;
NOTE: Writing HTML Body file: sashtml.htm
13 run;

NOTE: Input library XPTFILE is sequential.
NOTE: Copying XPTFILE.DMG to SASFILE.DMG (memtype=DATA).
NOTE: BUFSIZE is not cloned when copying across different
engines. System Option for BUFSIZE was used.
NOTE: There were 25 observations read from the data set
XPTFILE.DMG.
NOTE: The data set SASFILE.DMG has 25 observations and 14
variables.
NOTE: PROCEDURE COPY used (Total process time):
real time 6.37 seconds
cpu time 0.50 seconds


14 options nofmterr;

15 libname xptfile xport 'D:\SAS\Project\Project 3- Interating
15 ! Data for PKAnalysis\Project 3- Interating Data for
15 ! PKAnalysis\Work\02data_raw\formats.xpt';
NOTE: Libref XPTFILE was successfully assigned as follows:
Engine: XPORT
Physical Name: D:\SAS\Project\Project 3- Interating Data
for PKAnalysis\Project 3- Interating Data for
PKAnalysis\Work\02data_raw\formats.xpt
16 libname sasfile 'D:\SAS\Project\Project 3- Interating Data
16 ! for PKAnalysis\Project 3- Interating Data for
16 ! PKAnalysis\Work\04utility';
NOTE: Libref SASFILE was successfully assigned as follows:
Engine: V9
Physical Name: D:\SAS\Project\Project 3- Interating Data
for PKAnalysis\Project 3- Interating Data for
PKAnalysis\Work\04utility
17 proc copy inlib=xptfile outlib=sasfile;
18 options nofmterr;
19 run;

NOTE: Input library XPTFILE is sequential.
NOTE: Copying XPTFILE.FORMATS to SASFILE.FORMATS (memtype=DATA).
NOTE: BUFSIZE is not cloned when copying across different
engines. System Option for BUFSIZE was used.
NOTE: There were 500 observations read from the data set
XPTFILE.FORMATS.
NOTE: The data set SASFILE.FORMATS has 500 observations and 21
variables.
NOTE: PROCEDURE COPY used (Total process time):
real time 0.25 seconds
cpu time 0.04 seconds


20 libname form 'D:\SAS\Project\Project 3- Interating Data for
20 ! PKAnalysis\Project 3- Interating Data for
20 ! PKAnalysis\Work\04utility';
NOTE: Libref FORM refers to the same physical library as
SASFILE.
NOTE: Libref FORM was successfully assigned as follows:
Engine: V9
Physical Name: D:\SAS\Project\Project 3- Interating Data
for PKAnalysis\Project 3- Interating Data for
PKAnalysis\Work\04utility
21 proc format cntlin=sasfile.formats;
NOTE: Format BTPU11_ has been output.
NOTE: Format CHIP11_ has been output.
NOTE: Format CRN11_ has been output.
NOTE: Format DART11_ has been output.
NOTE: Format DOSR11_ has been output.
NOTE: Format ETH11_ has been output.
NOTE: Format HGTU11_ has been output.
NOTE: Format RCE51_ has been output.
NOTE: Format RSND21_ has been output.
NOTE: Format SEX11_ has been output.
NOTE: Format VOLU11_ has been output.
NOTE: Format WGTU11_ has been output.
NOTE: Format YNO11_ has been output.
22 run;

NOTE: PROCEDURE FORMAT used (Total process time):
real time 0.29 seconds
cpu time 0.15 seconds

NOTE: There were 500 observations read from the data set
SASFILE.FORMATS.

 

36 data PKDMG;
37 merge bapk (in=a) DMG (in=b);
38 format country sex DOB1D race;
39 keep country sex DOB1D race;
40 options nofmterr;
41 run;

NOTE: Variable country is uninitialized.
NOTE: Variable sex is uninitialized.
NOTE: Variable race is uninitialized.
WARNING: The variable country in the DROP, KEEP, or RENAME list
has never been referenced.
WARNING: The variable sex in the DROP, KEEP, or RENAME list has
never been referenced.
WARNING: The variable race in the DROP, KEEP, or RENAME list
has never been referenced.
NOTE: There were 300 observations read from the data set
WORK.BAPK.
NOTE: There were 25 observations read from the data set
WORK.DMG.
NOTE: The data set WORK.PKDMG has 300 observations and 1
variables.
NOTE: DATA statement used (Total process time):
real time 0.10 seconds
cpu time 0.09 seconds

Tom
Super User Tom
Super User

Looks like it worked.  But you need to check what the names of the variables are.  There are no variables named COUNTRY SEX or RACE in those two datasets.

Tejaswini3
Obsidian | Level 7

When I open those individual dataset, am able to see the variable.

 

May be because of format issue, its not able to recognise

Tom
Super User Tom
Super User

@Tejaswini3 wrote:

When I open those individual dataset, am able to see the variable.

 

May be because of format issue, its not able to recognise


Your explanations are too brief to really understand what your issue is.  You posted code that could successfully convert two XPT files into datasets. And convert the FORMATS dataset into a format catalog in the WORK directory.  But then you also show code that is trying to reference some potentially unrelated datasets.    

 

If you can see the variable then tells us how it is defined.  What is the NAME of the variable? The TYPE? The storage LENGTH?  Does it have a FORMAT attached? If so what format?  Does it have a LABEL attached?  If so what is the label?

 

The DMG dataset you created from the dmg.xpt file only has 14 variables.  Just run PROC CONTENTS and show us the output from that. It should list each variable with its position number, name, type , length and if attached any format or label. It might also show if it has an informat attached, but for an existing dataset an informat does not really play much of a role.

 

Remember when pasting text like code or lines from the SAS log to paste them into the pop-up boxes that the forum editor will open when you click on the Insert Code or Insert SAS code button.  That will prevent the forum from re-flowing the text as if it were paragraphs.

 

So here is basic code to convert DMG and FORMATS into a dataset and a catalog in that 04utility folder in your code.

options nofmterr;

%let path=D:\SAS\Project\Project 3- Interating Data for PKAnalysis\Project 3- Interating Data for PKAnalysis\Work;

libname utility       "&path\04utility";
libname xptlib1 xport "&path\02data_raw\dmg.xpt";
libname xptlib2 xport "&path\02data_raw\formats.xpt";

proc format fmtlib cntlin=xptlib2.formats lib=utility ;
run;

proc copy inlib=xptlib1 outlib=utility;
run;

To tell SAS to use that formats catalog you can add it to the search path used by using the APPEND option like this:

options append=(fmtsearch=(utility.formats));

Now you can run code to look at the DMG dataset.  Since it is small I would would just print the whole thing.  I would print it twice, once using the formats and once without the formats.

proc print data=utility.dmg;
title 'formatted values';
run;
proc print data=utility.dmg;
  format _all_ ;
  title 'unformatted values';
run;
title;
Kurt_Bremser
Super User

When SAS tells you that a variable is not there, then it is not there, period.

 

The existence of a format is irrelevant here. You are using variable names in your data step that cannot be found in the input datasets. Run PROC CONTENTS on your datasets to see the names of all variables contained.

Kurt_Bremser
Super User

Always (as in ALWAYS) post logs by copy/pasting the log text directly into a window opened with this button:

Bildschirmfoto 2020-04-07 um 08.32.59.jpg

There is absolutely no need to take a screenshot and insert the picture, copy/pasting is much easier for you and the text is much easier to read and commentate on.

 

I do not see the PROC FORMAT code I gave you.

Kurt_Bremser
Super User

To recreate a format, you need either

  • the PROC FORMAT code that created the format (preferred)
  • a CNTLIN dataset for PROC FORMAT for automated creation (next best option)
  • a catalog containing the format (least preferred, because catalogs are platform- and SAS version dependent)

A CNTLIN dataset has (at least) the columns fmtname, start and label.

 

PROC FORMAT is a procedure that needs a RUN;, not a QUIT;

 

So which types of SAS files are contained in your XPT file? Only datasets (then look for one with the above mentioned structure) or catalogs also?

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 24 replies
  • 4683 views
  • 0 likes
  • 3 in conversation